我有一张图片,在页面加载后会淡入。然而,动画中设置的图像最终透明度并没有保留。以下是我图片的(简单)XML代码:
<ImageView
android:id="@+id/myImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cropToPadding="true"
android:scaleType="centerCrop"
android:background="#ffffff" />
然后我有一个动画文件,它淡入了图片:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha
android:fromAlpha="0.0"
android:toAlpha="0.6"
android:duration="2000"/>
</set>
最后是加载图片的代码:
body =(ImageView)findViewById(R.id.myImage);
body.setBackgroundDrawable(new BitmapDrawable(this.getResources(), background));
Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein_bg);
body.startAnimation(myFadeInAnimation);
那么,动画完成后我如何使图像的最终阿尔法值保持不变呢?谢谢。