2014-11-05 80 views
1

我有這樣的事情。背景透明和前景較暗

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:fb="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="@drawable/blue_bg" 
tools:context="com.example.budgetme.MainActivity" > 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hello_world" /> 

如何使 「機器人:背景=」 @繪製/ blue_bg」透明的,另一個按鈕,Textviews等更黑暗,更 「看到」 提前

+0

你想要什麼?清楚地解釋。 – 2014-11-05 07:00:17

+0

您可以使用具有alpha值的顏色代碼使其透明,如'android:background =「#550000FF」'這裏前兩個字符表示alpha值,其餘6個字符代表顏色代碼。 – dakshbhatt21 2014-11-05 07:01:48

+0

'android:alpha =「0.40」'使背景半透明。 – 2014-11-05 07:02:43

回答

1

嘗試

謝謝像這樣,

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:fb="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:alpha="0.8" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:background="@drawable/blue_bg" 
tools:context="com.example.budgetme.MainActivity" > 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hello_world" /> 

可以設置通過設置值機器人更透明度:阿爾法= 「0至1」

+0

這使得即使是透明的Textview。 我只需要背景圖片是透明的。 – Jay 2014-11-05 07:53:37

0

一種方法是在colors.xml文件中定義您的blue_bg。例如:

<color name="blue_bg">#??3f51b5</color> 

其中?? ??可以根據透明性與十六進制替換即

100% - FF, 90% - E6, 80% - CC, 70% - B3, 60% - 99, 50% - 80%, 40 % - 66, 30% - 4D, 20% - 33, 10% - 1A, 0% - 00

我希望這有助於。

0

在你drawable-> blue_bg 更換(說妳使用下面的顏色代碼)

<solid android:color="#462D85" /> 

<solid android:color="#4D462D85" /> 

70%的透明度

休息不透明值are-- -

100% — FF 
95% — F2 
90% — E6 
85% — D9 
80% — CC 
75% — BF 
70% — B3 
65% — A6 
60% — 99 
55% — 8C 
50% — 80 
45% — 73 
40% — 66 
35% — 59 
30% — 4D 
25% — 40 
20% — 33 
15% — 26 
10% — 1A 
5% — 0D 
0% — 00