2013-12-09 118 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