参考链接:
http://blog.csdn.net/imdxt1986/article/details/6952943
为控件设置动画效果
1、可以在xml文件中设置;
2、可以在java代码中设置。
首先,在 res/anim 文件夹下新建slide_right.xml ,如下:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="@android:integer/config_shortAnimTime" />
</set>
随后,在 res/anim 文件夹下新建 list_anim_layout.xml , 如下:
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="30%"
android:animationOrder="reverse"
android:animation="@anim/slide_right"
/>
1、在xml文件中设置动画;
直接为控件添加如下配置:
<span style="font-size:18px;">android:layoutAnimation="@anim/list_anim_layout"</span>
例如:
<span style="font-size:18px;"><TextView
android:id="textView1"
android:text="myTextView"
android:layoutAnimation="@anim/list_anim_layout">
</TextView></span>
2、在java代码中设置:
Animation anim = AnimationUtils.loadAnimation(getBaseContext(), R.anim.slide_right);
LayoutAnimationController lac = new LayoutAnimationController(anim);
lac.setOrder(LayoutAnimationController.ORDER_RANDOM);
lac.setDelay(1);
控件名.setLayoutAnimation(lac)