【发布时间】:2011-09-26 05:48:48
【问题描述】:
当在我的 ListView 中按下它时,我试图将透明背景应用于我的行。我像这样创建文件 list_selector.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/argb80804040" />
</selector>
在我的 news_item.xml 中,我将背景定义如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_selector">
<ImageView
android:id = "@+id/img"
android:layout_width="95dip"
android:layout_height="75dip"
android:layout_alignParentLeft = "true"
android:paddingTop="10dip"
android:layout_marginLeft="10dip"
android:paddingBottom="10dip"
android:src="@drawable/no_news_image_small" />
<TextView android:id="@+id/title"
android:layout_gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="bold"
android:paddingTop="5dip"
android:layout_marginLeft="110dip"
android:textColor="#21B6EF"
android:singleLine="true" />
<TextView android:layout_gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_weight="1.0"
android:layout_height="wrap_content"
android:layout_marginLeft="110dip"
android:textSize="10sp"
android:id="@+id/description"
android:layout_below="@id/title"
android:paddingBottom="10dip"
android:layout_marginBottom="5dip"
android:textColor="#fff"/>
</RelativeLayout>
但是,它显示为纯色而不是 ARGB 颜色。我的drawable定义如下:
<resources>
<item type="drawable" name="transparent_orange">#64ff7b00</item>
<item type="drawable" name="argb80804040">#80804040</item>
<item type="drawable" name="argb40000000">#40000000</item>
<item type="drawable" name="argb80408040">#80408040</item>
</resources>
我是否需要做其他事情才能使 aplha 颜色正常工作?我正在我自己的设备上尝试(motorola defy),并且我还在使用另一个使用相同 alpha 颜色的应用程序,并且该颜色在此应用程序中看起来不错,但在我的设备中却没有。
非常感谢您的任何回复 T
【问题讨论】:
标签: android