每次单击按钮时,我都想制作一个淡入淡出动画。我开始只检查淡出,在第一次点击时,淡出似乎工作得很好。但是当我再次单击时,动画会从上到下淡出,使它看起来很糟糕并且被剪掉了。
动画:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="1000" />
</set>
编码:
Animation fadeOut = AnimationUtils.loadAnimation(myActivity.this, R.anim.fade_out);
LinearLayout myBackground=(LinearLayout)findViewById(R.id.myBackground);
myBackground.setAnimation(fadeOut);
我错过了什么?谢谢!