简体   繁体   中英

Background transparent and foreground darker

I have something like this.

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

How do make the "android:background="@drawable/blue_bg" transparent and the other buttons,Textviews,etc more darker and more "SEEN"

Thanks in advance

try like this,

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

you can set more transparency by setting value android:alpha="0 to 1"

One way is to define your blue_bg in the colors.xml file. For example:

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

where ?? you can replace with hex according to transparency ie

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

I hope this helps.

In your drawable-> blue_bg replace (say u use the following color code)

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

to

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

for 70% transparency

rest opaque values 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM