【发布时间】:2013-12-09 15:37:16
【问题描述】:
我为android界面制作了一个xml文件。在这个 xml 中,有一个消耗品。我想用透明(alpha)为这个xml添加背景,但是当我在相对布局中添加bacground时,像这样
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:alpha="0.2"
tools:context=".ListGestureActivity" >
这将使背景透明度变为黑色而不是白色。在其他 xml 中也发生了这样的事情。 但在其他 xml 中我尝试这样做
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".HintGestureActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:alpha="0.3"
android:background="@drawable/background"
/>
成功了。但是在带有消耗性物品的xml中不起作用。 你有什么建议吗?
【问题讨论】:
-
@drawable/background 的值是多少?
-
在
AndroidMenifest.xml中,您为activity使用的是哪个主题?Dark还是Light?如果是Dark,则设为Light并尝试一下。告诉结果。 -
@drawable/bacground 是我想要作为背景的图像
-
致 MrSuS -- 我不使用任何主题
标签: android xml background alpha-transparency