2013-12-09 121 views
2

我为android界面制作了一个xml文件。在这个XML中,有一个消耗品。我想补充的背景为这个XML与tansparency(阿尔法),但是当我与阿尔法添加bacground中相对布局这样android在xml中的背景:tranparency变成黑色不是白色

<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没有工作。 你有什么建议吗?

+0

@ drawable/background的值是多少? –

+0

在'AndroidMenifest.xml'中,您正在使用哪个主题进行“活动”? “黑暗”还是“光明”?如果“黑暗”,使它“光”,并尝试它。告诉结果。 –

+0

@ drawable/bacground是我想让它为背景的图像 – user3029956

回答

0

U可以做这样的事情

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" 
    /> 
+0

我想让@ drawable/background作为我的界面背景 – user3029956

+0

color--“#00564678”是透明的颜色。仅使用此设置背景。 – AndroidHacker

0

默认情况下,它需要黑色作为背景颜色,并在此之后,如果你申请的透明度,那么你不会得到因此,首先你需要设置一些背景颜色,然后在其上应用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" > 
+0

我想让@ drawable/background作为我的界面背景 – user3029956

+0

“制作@ drawable/backgroud作为你的界面”是什么意思?我没有得到你想要做的事情? – zanky