Reputation: 123
I want to set my background of LinearLayout and textview with black-transparent color so that the picture behind them can be seen well.
I tried with the code below, but it doesn't work
<TextView
android:id="@+id/text_feed_myPlant_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Comments"
android:textSize="22dp"
android:layout_alignParentBottom="true"
android:paddingLeft="10dp"
android:background="@android:color/transparent"/>
Upvotes: 2
Views: 1712
Reputation: 131
Or you can use alpha
<TextView
android:id="@+id/text_feed_myPlant_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Comments"
android:textSize="22dp"
android:alpha="0.5"
android:layout_alignParentBottom="true"
android:paddingLeft="10dp"
android:background="#FFFFFF"/>
Upvotes: 0
Reputation: 1733
Try this;
Style.xml
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
Color.xml
<color name="transparent">#CCFFFFFF</color>
If you want change transparent Layout;
Layout.xml
<activity android:name="com.ex.ex"
android:theme="@style/Theme.Transparent">
</activity>
And Text View
<TextView
android:id="@+id/text_feed_myPlant_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Comments"
android:textSize="22dp"
android:layout_alignParentBottom="true"
android:paddingLeft="10dp"
android:background="#CCFFFFFF"/>
Upvotes: 2
Reputation: 1170
Try this
<TextView
android:id="@+id/text_feed_myPlant_comments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No Comments"
android:textSize="22dp"
android:layout_alignParentBottom="true"
android:paddingLeft="10dp"
android:background="#CCFFFFFF"/>
You can change the transparency by changing first two character("CC") with below codes
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
Upvotes: 2