Search code examples
androidbackgroundopacity

50% opacity at white background for textview


I am trying to set #ffffff(white) background at 50% opacity to TextView.
I tried to use android:alpha=0.5 but it's also making text 50% transparent.

I need to set 50% opacity at white background.
I find one tutorial Here but don't understand that much.

Please provide me any reference. Thanks in Advance.


Solution

  • In your layout file just set the background of the TextView to "#8FFF"

    <TextView
    android:layout_width="..."
    android:layout_height="..."
    android:background="#8FFF"
    />
    

    Here 8 is the alpha value, FFF are the RGB values respectivley. See here for more info on the background attribute