【问题标题】:How to make text color as transparent in listview android?如何在listview android中使文本颜色透明?
【发布时间】:2014-01-14 23:54:49
【问题描述】:
我需要根据背景图像更改文本颜色。我的背景图片包含多种颜色。因此,我必须更改我的 textview 颜色。
<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"/>
请指导我,如何做到这一点。
【问题讨论】:
标签:
java
android
textview
transparent
【解决方案1】:
基本上,您可以选择使用 android:background 设置透明度(不透明度)和颜色。
您设置的十六进制值由 3 到 4 部分组成:
Alpha(不透明度),我将其称为 aa
红色,我称它为rr
绿色,我称它为gg
蓝色,我称它为bb
没有 alpha(透明度)值:
android:background="#rrggbb"
带有 alpha(透明度)值:
android:background="#aarrggbb"
全透明的alpha值为00,不透明的alpha值为FF
您可以尝试介于两者之间的值。
【解决方案2】:
试试android:textColor="#00000000"。此代码仅适用于透明色。
【解决方案3】:
当您设置文本颜色时,请尝试使用#24ffffff 或其他组合,前两位数字用于 alpha,您可以调整文本的不透明度。
【解决方案4】:
设置文字颜色:#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" />
检查这个link
【解决方案5】:
要获得任何颜色的透明度,请根据您对透明度级别的要求在颜色代码前添加88 或44。
例如,要获得黑色透明色,请使用代码“#88000000”
所以只需获取您的颜色代码并为其添加前缀并设置颜色,如下例所示。
android:textColor="#88000000"