Thursday, April 18, 2013

Android Button Animation Example

The Android Development Tutorials blog contains Basic as well as Advanced android tutorials.Go to Android Development Tutorials to get list of all Android Tutorials.

How To Animate a Button

We need a xml file that will define the Animation.

Create a folder named  "anim"  in res folder

Create a xml file named vanish.xml,  in this file we will define our Animation.

vanish.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" >
   
<scale android:duration="300"     // duration in miliseconds
       android:fromXScale="1.0"    //  X scaling to start from
       android:fromYScale="1.0"    // Y scaling to start from
       android:toXScale="1.5"      
       android:toYScale="1.5"
       android:pivotX="40%"
       android:pivotY="40%"
       android:interpolator="@android:anim/decelerate_interpolator"/>
      

<alpha android:duration="300"
       android:fromAlpha="1.0"
       android:toAlpha="0.0"
       android:interpolator="@android:anim/decelerate_interpolator"/>
   
</set>



In your Activity class create the reference of the Button on which you want apply the animation.

Animation vanish =AnimationUtils.loadAnimation(this,R.anim.vanish);
findViewById(R.id.youButton).startAnimation(vanish).



You can change the following attributes acoording your requirement

      android:duration="300"         
      android:fromXScale="1.0"    
       android:fromYScale="1.0"         
      android:toXScale="1.5"      
       android:toYScale="1.5"
       android:pivotX="40%"
       android:pivotY="40%"


Android Animation Examples:


Animating  ImageViews




Layout Animations
Sliding Between Screen  Using ViewFlipper





More Android Topics

New Advance Topics:
Android ImageSwitcher                    Android TextSwitcher                                Android ViewFlipper
Android Gesture Detector               Handling/Detecting Swap Events                Gradient Drawable
Detecting Missed Calls                    Hide Title Bar                                           GridView Animation

 Beginning With Android
      Android : Introduction                                                              Configuring Eclipse for Android Development
     Creating Your First Android Project                                           Understanding Android Manifest File of your android app

 Advance Android Topics                                                              Customizing Android Views


Working With Layouts                                                                Working With Views

Understanding Layouts in Android                                                   Using Buttons and EditText in Android
Working with Linear Layout (With Example)                                     Using CheckBoxes in Android
Nested Linear Layout (With Example)                                              Using AutoCompleteTextView in Android                                                                                          Grid View
Relative Layout In Android                                                               ListView
Table Layout                                                                                   Android ProgressBar
Frame Layout(With Example)                                                          Customizing ProgressBar
Absolute Layout                                                                             Customizing Radio Buttons
Grid Layout                                                                                    Customizing Checkboxes In Android

Android Components                                                                 Dialogs In Android

Activity In Android                                                                    Working With Alert Dialog
Activity Life Cycle                                                                    Adding Radio Buttons In Dialog
Starting Activity For Result                                                       Adding Check Boxes In Dialog
Sending Data from One Activity to Other in Android                    Creating Customized Dialogs in Android
Returning Result from Activity                                                   Creating Dialog To Collect User Input
Android : Service                                                                     DatePicker and TimePickerDialog
BroadcastReceiver                                                                   Using TimePickerDialog and DatePickerDialog In android

Menus In Android                                                                ListView:
Creating Option Menu                                                               Populating ListView With DataBase
Creating Context Menu In Android                                              Populating ListView with ArrayList
                                                                                               ListView with Custom Adapter

Toast                                                                                      Working With SMS
Customizing Toast In Android                                                       How to Send SMS in Android
Customizing the Display Time of Toast                                        How To Receive SMS
Customizing Toast At Runtime                                                  Accessing Inbox In Android
Adding Image in Toast
Showing Toast for Longer Time


TelephonyManager                                                            Storage: Storing Data In Android
Using Telephony Manager In Android                                          SharedPreferences In Android
                                                                                              Reading and Writing files to Internal Stoarage
Working With Incoming Calls                                             DataBase
How To Handle Incoming Calls in Android                                Working With Database in Android
How to Forward an Incoming Call In Android                            Creating Table In Android
CALL States In Android                                                          Inserting, Deleting and Updating Records In Table in Android


Miscellaneous
Notifications In Android
How To Vibrate The Android Phone
Sending Email In Android
Opening a webpage In Browser
How to Access PhoneBook In Android
Prompt User Input with an AlertDialog





18 comments:

  1. Very informative post.I am really impressed by this incredible precious site.

    android application development

    ReplyDelete
  2. i want to create 3d live wallpaper in which there is day and night detector,talking digital clock and also talking battery warning,can anyone help me its my project?i am new to developing

    ReplyDelete
  3. great :)
    it is very helpful ,we can save our course fee by doing it .great site.

    ReplyDelete
  4. it was very informative information for me, thanks for post.

    ReplyDelete
  5. Its very informative. I was searching it from some time.


    [url=http://webdesignandappdevelopment.com/] Professional web design company[/url]

    ReplyDelete
  6. good information. Thanks for such post

    ReplyDelete
  7. Thanks it enhanced my knowledge.

    ReplyDelete
  8. you always write informative notes.

    ReplyDelete
  9. very nice information thanks.

    ReplyDelete
  10. very nice information thanks for the post.

    ReplyDelete
  11. I like your post thanks for the information.

    ReplyDelete
  12. you write a nice information thanks.

    ReplyDelete