【问题标题】:Add a semi-opaque black layer over a background image in Android TextView在 Android TextView 中的背景图像上添加半透明黑色层
【发布时间】:2011-11-15 04:37:52
【问题描述】:

这就是我想要做的:

我有一个 .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:background="@color/blackOpaque"> 但是 Eclipse 抱怨我已经有了背景图像。所以我试着像这样改变我的图像文件的透明度:

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

但似乎什么都没有发生。

我该怎么办?谢谢!

谢谢!

【问题讨论】:

    标签: android background drawable transparent


    【解决方案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" />      
    

    【讨论】:

      猜你喜欢
      • 2012-02-29
      • 2011-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-26
      • 1970-01-01
      相关资源
      最近更新 更多