android的xml背景:交易变黑而不是变白
我为android界面制作了一个xml文件。在这个xml中,有一个可消耗项。我想用tansparency(alpha)为这个xml添加背景,但是当我用alpha在相对布局中添加bacground时,就像这样android的xml背景:交易变黑而不是变白,android,xml,background,alpha-transparency,Android,Xml,Background,Alpha Transparency,我为android界面制作了一个xml文件。在这个xml中,有一个可消耗项。我想用tansparency(alpha)为这个xml添加背景,但是当我用alpha在相对布局中添加bacground时,就像这样 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width=
<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" >
android:background="#00564678"
这将使背景透明度变为黑色而不是白色。在另一种情况下,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中,使用一次性物品是不起作用的。
你有什么建议吗?你可以这样做
<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" >
android:background="#00564678"
例如:
<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="#00564678"
/>
默认情况下,它将黑色作为背景色,然后,如果应用透明度,则将无法获得所需的输出。因此,首先需要在应用
alpha
之后设置一些背景色。试试这个:
<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"
android:alpha="0.2"
tools:context=".ListGestureActivity" >
在AndroidMenifest.xml
中,@drawable/background?的值是多少,您用于活动的主题是什么<代码>暗
或亮
?如果暗
,则将其设置为亮
,然后重试。告诉结果。@drawable/bacground是我想制作的图像,作为MrSuS的背景——我不使用任何主题我想制作@drawable/background作为我的界面背景你说的“制作@drawable/background
作为你的界面”是什么意思?我不明白你想做什么?我想让@drawable/background作为我的界面背景色--“#00564678”是透明色。只需使用此设置背景。