Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Black color comes instead a transparent background for textview in android

The following two pics are a TextView with the following properties in it:

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_style"
            android:text="select password"
            android:textColor="@color/dif_black"/>

and the button_style.xml is

<?xml version="1.0" encoding="UTF-8"?>
<layer-list >
<item>
    <shape>
        <stroke
            android:width="2dp"
            android:color="#88C425" />
        <corners android:radius="20dp" />
    </shape>
</item>

First pic taken from Canvas 2, Second pic taken from Samsung Galaxy Fame . Here is the problem I don't want the black color to be filled inside the textview border(Stroke). You would have noticed in the first pic that the background of the textview is transparent. I want this same in all android devices to be a transparent background.

First picture with transparent background comes for Canvas 2enter image description here

like image 820
Akbarsha Avatar asked Dec 09 '13 05:12

Akbarsha


People also ask

How do I make text transparent on Android?

Set the Alpha value to 00 (hex) to make any color fully opaque. Set the Alpha value to ff (hex) to make it transparent (the color doesn't matter anymore).

Is there a color code for transparent?

You can actually apply a hex code color that is transparent. The hex code for transparent white (not that the color matters when it is fully transparent) is two zeros followed by white's hex code of FFFFFF or 00FFFFFF.


1 Answers

You have specified only the stroke of the Shape, but it needs background. It seems that black is default.

Change your button_style.xml shape by adding the solid transparent background:

<shape>
    <stroke
        android:width="2dp"
        android:color="#88C425" />
    <corners android:radius="20dp" />
    <solid android:color="@android:color/transparent" />
</shape>
like image 63
Glib Ischenko Avatar answered Oct 09 '22 17:10

Glib Ischenko