I want to set a transparent black color to my textview
background color. How can I do it?
Asked
Active
Viewed 1.1k times
3

BenMorel
- 34,448
- 50
- 182
- 322

dilaraates
- 135
- 1
- 1
- 16
-
Transparent or black because transparent black doesn't make sense :) – ania Aug 10 '12 at 12:19
-
Actually I need light black like dialog box background Is this possible? – dilaraates Aug 10 '12 at 12:21
-
2You can refer this link Transparent This link is helpful to you. – Dinesh Lingam Aug 10 '12 at 12:22
-
[this ](http://stackoverflow.com/questions/6608947/android-transparent-textview) may help you to give transparent background for a text view. – android Aug 10 '12 at 12:21
4 Answers
8
android:background="#55000000"
If you use a color with 8 numbers instead of 6, the first two set the opacity. in this case, the opacity is 0x55 which is 85/255 [roughly 33% opacity].
for programatic, you should be able to use the following (where myTextView corresponds to your View)
myTextView.setBackgroundColor(0x55000000);

binary_falcon
- 302
- 3
- 11
3
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>
<gradient
android:startColor="#2fDEDEDE"
android:endColor="#2F000000"
android:angle="270" />
<stroke
android:color="#cbc9c9" />
<corners
android:radius="3dp" />
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" />
</shape>
</item>
<item>
<shape>
<gradient
android:startColor="@android:color/transparent"
android:endColor="@android:color/transparent"
android:angle="270" />
<stroke
android:color="#c3c2c2" />
<corners
android:radius="4dp" />
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" />
</shape>
</item>
usage:==>
android:background="@drawable/btn_trans"
if you want to set black color
android:background="#000"

Ram kiran Pachigolla
- 20,897
- 15
- 57
- 78
0
make a image transparent in photoshop and apply it to textview background... thats it , you have got transparent background to text view

Pranav Sharma
- 692
- 2
- 9
- 22
0
Set backgroud color as follows
android:background="@android:color/transparent"

Rahmathullah M
- 2,676
- 2
- 27
- 44