加载XML动画:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="10%p" android:toYDelta="0" android:duration="800"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="800"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="1000" />
</set>
Activity中引入Animation
mShowAction = AnimationUtils.loadAnimation(this, R.anim.push_up_in);
mHiddenAction = AnimationUtils.loadAnimation(this, R.anim.push_up_out);
mOne.setVisibility(View.VISIBLE);
mOne.startAnimation(mShowAction);
Activity中自定义Animation
mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, -6.0f, Animation.RELATIVE_TO_SELF, 0.0f);
mShowAction.setDuration(1500);
increaseTV.setAnimation(mShowAction);
本文介绍了如何在Android中使用XML文件定义动画效果,并展示了如何加载这些动画以及自定义动画的具体实现方式。
822

被折叠的 条评论
为什么被折叠?



