2014-11-05 65 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