我想做一个维基喜欢的活动,其中有一个从回购下载的褪色背景图像,并淡入到线性布局背后的背景。我有三个问题。设置背景图像在背景中褪色
XML:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/bg_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cropToPadding="true"
android:scaleType="centerCrop" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:textColor="#FFFFFF" >
<LinearLayout>Several layouts within here....</LinearLayout>
</LinearLayout>
</FrameLayout>
1)我可以得到图像显示,但直到我打开另一个应用程序的的LinearLayout内的一些一些元素不是透明的,然后回到我的应用程序。我认为可能会有一些奇怪的视图缓存内置到android中,导致像linearlayouts这样的东西有一个坚实的背景。
2)我无法让图像在背景中“消失”。我几乎想要将图像变暗,使其上方的文字更加突出。这是不透明的图像?
3)淡入的动画不起作用。我正在使用AsyncTask来回调侦听器来设置背景。下面是我在活动中使用的代码,InfoActivity:
bg =(ImageView)findViewById(R.id.bg_image);
public void onBgImageResponse(Bitmap background) {
if(background != null) {
bg.setAlpha(50);
bg.setImageBitmap(background);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(InfoActivity.this, R.anim.fadein_bg);
bg.setBackgroundDrawable(new BitmapDrawable(this.getResources(), background));
bg.startAnimation(myFadeInAnimation);
}
}
在fadein_bg.xml我:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha=".5"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="2000" android:repeatCount="infinite"/>
</set>
任何帮助是极大的赞赏。如果需要的话,我会付出一笔赏金。
重复计数和内插器是问题 – Du3 2012-01-31 14:52:01