4

I need to change Text color based on background image. My background image contains multiple colors. So, accordingly i have to change my textview color.

  <TextView    android:id="@+id/txtbloops_flower"
               android:layout_height="wrap_content"
               android:layout_width="wrap_content"
               android:textSize="16dp"
               android:layout_centerInParent="true"
               android:layout_marginLeft="10dp"
               android:textColor="#ffffff"/>

enter image description here

please guide me, how to do this.

Community
  • 1
  • 1
koti
  • 1,071
  • 3
  • 15
  • 35

5 Answers5

7

Basically you have the option to set the transparency (opacity) and the color using android:background.

The hex value that you set it to is composed of 3 to 4 parts:

  • Alpha (opacity), i'll refer to that as aa

  • Red, i'll refer to it as rr

  • Green, i'll refer to it as gg

  • Blue, i'll refer to it as bb

Without an alpha (transparency) value:

android:background="#rrggbb"

With an alpha (transparency) value:

android:background="#aarrggbb"

The alpha value for full transparency is 00 and the alpha value for no transparency is FF

You can experiment with values in between those.

Shyam
  • 6,376
  • 1
  • 24
  • 38
  • Hey, you should refer to the original post if this answer was copied from somewhere else: http://stackoverflow.com/questions/6608947/android-transparent-textview – Roger Huang Apr 27 '16 at 10:16
5

Try out with android:textColor="#00000000". This code is for the transparent color only.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
1

When you set the text color try using #24ffffff or some other combination, the first two digits are for the alpha, and you can adjust the opacity of the text.

Ayoub
  • 341
  • 1
  • 13
0

set text color: #80000000

<TextView
            android:id="@+id/txtbloops_flower"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="10dp"
            android:text="hello dhaval"
            android:textColor="#80000000"
            android:textSize="16dp" />

check this link

Community
  • 1
  • 1
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
0

To get transparency in any of your color add 88 or 44 before your color code as per your requirement of transparency level. for example, to get black transparent color use code "#88000000"

so just get your color code and add the prefix to it and set the color as below example.

android:textColor="#88000000"
AndyN
  • 1,742
  • 1
  • 15
  • 30