Tuesday, February 7, 2012

Android Set animation for dialog

Android :Set animation for dialog

Problem:

*How to set animation for Dialog.

Solution:

Below i added code for how to set animation for Dialog.
it will use full for increase attractive our apps.

Dialog dlg = new Dialog(this);
dlg.getWindow().getAttributes().windowAnimations = R.style.Animations_SmileWindow;


XML style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
          <style name="Animations" />
         <style name="Animations.SmileWindow">
                <item name="@android:windowEnterAnimation">@anim/grow_from_bottom</item>
                <item name="@android:windowExitAnimation">@anim/grow_from_top</item>
        </style>
       
</resources>


Xml anim code

grow_from_bottom.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale
                android:fromXScale="0.3" android:toXScale="1.0"
                android:fromYScale="0.3" android:toYScale="1.0"
                android:pivotX="50%" android:pivotY="100%"
                android:duration="@android:integer/config_shortAnimTime"
        />
        <alpha
                android:interpolator="@android:anim/decelerate_interpolator"
                android:fromAlpha="0.0" android:toAlpha="1.0"
                android:duration="@android:integer/config_shortAnimTime"
        />
</set>

grow_from_top.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
        <scale
                android:fromXScale="0.3" android:toXScale="1.0"
                android:fromYScale="0.3" android:toYScale="1.0"
                android:pivotX="50%" android:pivotY="0%"
                android:duration="@android:integer/config_shortAnimTime"
        />
        <alpha
                android:interpolator="@android:anim/decelerate_interpolator"
                android:fromAlpha="0.0" android:toAlpha="1.0"
                android:duration="@android:integer/config_shortAnimTime"
        />
</set>


14 comments:

  1. This is one of the thoughtful and good post.Android is one of the fast moving mobile application due to its incredible features.

    ReplyDelete
  2. hi vijaykumar ,im also a android developer,,, im from salem. Your posts are too good.keep it up.

    ReplyDelete
  3. plz fix this http://stackoverflow.com/questions/4755655/add-onclick-to-button-inside-custom-status-bar-view

    ReplyDelete
  4. "I always feel happy u know why? i don't except anything from anyone !!!because expectations always hurts lot",,,

    ReplyDelete
  5. http://androidroadies.blogspot.in/

    ReplyDelete
  6. Hi vijayakumar iam newby in android plz give some tutorial how to make animated imagebutton android:src plz help me..

    ReplyDelete
  7. This comment has been removed by a blog administrator.

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...