2011-11-13 40 views
2

背景图像这是我想要做的事:添加半透明的黑色层在Android中的TextView

我有一个PNG图片作为背景为我的TextView;文本的颜色是白色的。为了使文本更易于阅读,我想在我的.png图像上添加一个不透明的黑色图层。

这是我迄今所做的:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/aboutContent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:text="@string/aboutEN" 
     android:textColor="#FFFFFF" 
     android:background="@drawable/myimage"/> 

我尝试添加的android:背景=“@颜色/ blackOpaque”> 但是Eclipse抱怨说,我已经有了一个背景图像。所以我试图改变我的图像文件的透明度,如下所示:

Drawable myimage = getResources().getDrawable(R.drawable.myimage); 
myimage.setAlpha(50); 

但是没有任何事情发生。

我该怎么办?谢谢!

谢谢!

回答

1

This saved my @$$!

<merge xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:scaleType="center" 
     android:background="@drawable/myimage" /> 

    <TextView android:id="@+id/aboutContent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="@string/aboutEN" 
     android:background="#AA000000" 
     android:textColor="#ffffff" />  

相关问题