在Android中应用alpha后文本颜色会发生变化

时间:2015-07-20 19:58:29

标签: android colors transparency alpha

我有一个custom_row.xml,它将成为使用BaseAdapter的ListView的一部分

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
 android:background="anyBackgroundColor(#HexValue)">

     inner content has text view of white color

  </RelativeLayout>

enter image description here

将Alpha属性应用于RelativeLayout后,文本颜色变得微弱。

enter image description here

我不希望文字变得模糊,并且我的背景颜色也不是图像的透明度。 我们如何才能实现这一目标?

1 个答案:

答案 0 :(得分:0)

当您将alpha应用于布局时,您实际上是在布局包含的所有内容上应用alpha。这就是为什么你的文字也变得部分透明了。

Android中颜色的十六进制值定义为AARRGGBB - alpha,红色,绿色和蓝色。因此,更改AA00 - 完全透明,FF - 不透明)部分颜色十六进制代码将使您的布局背景颜色透明,保留其中包含的其他视图。

例如

android:background="#66D500F9" -> alpha part is 66