I would like provide and animation effect but i don't how to do. Even i don't know what type of effect it should be called so that i can search on Google.
So my problem is ..
when user click a button a view or a layout should be display. i want to give effect to that view like ... it should be look like that that view is coming from left side of screen to right side and finally it should display my view.
modification like you want:
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(1000);
animation.setStartOffset(0);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(1000);
set.addAnimation(animation);
You can also check the API demos in the Android sdk. There are a few animations demo (in Views > Animations).
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(1000);
animation.setStartOffset(0);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
-1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(1000);
set.addAnimation(animation);
public static android.view.animation.Animation in;
in = AnimationUtils.loadAnimation(ctx, R.anim.slide_in);
view.startAnimation(in);
you may define the animation in a seperat xml like:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="300" />
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:startOffset="0"
android:duration="300" />
edit: here a animation from left to right, play a bit around:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromXDelta="-100%p"
android:toXDelta="0"
android:duration="150" />
精彩评论