我有以下 2 个布局文件来显示联系人组列表。正常状态下的 View 看起来很完美。我背景上的半透明列表项。当我触摸列表以移动它时,背景变为黑色而不是保持半透明。
gouplist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/megaphone_320x480">
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No Groups"
/>
</LinearLayout>
two_line_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/lv_topText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#BBBBBB"
android:background="#99000000"
android:textSize="24sp"
android:typeface="sans"
android:textStyle="bold"
/>
<TextView
android:id="@+id/lv_bottomText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#BBBBBB"
android:background="#99000000"
android:textSize="18sp"
android:typeface="sans"
android:textStyle="bold"
/>
</LinearLayout>
最佳答案
cacheColorHint 属性需要在实际的 ListView 上设置,就像这样。正如 3dmg 所述,它通常会设置为与 ListView 所在容器相同的背景颜色。在下面的示例中,ListView 将位于同样具有白色 (#FFF) 背景的 LinearLayout 内。
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1.0"
android:cacheColorHint="#FFF" />
关于android - 在选定的 ListView 上设置背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5325329/