简体   繁体   中英

How to make text color as transparent in listview android?

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"/>

在此输入图像描述

please guide me, how to do this.

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.

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

当您使用#24ffffff或其他组合设置文本颜色时,前两个数字用于alpha,您可以调整文本的不透明度。

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM