12
我试图在下列条件下使用的棒棒糖列表视图控件:列表视图设置自定义的纹波选择
- 的主题类型是默认Theme.Material(黑暗的主题)。
- 列表视图包含在具有白色背景的较大布局中。
- 列表视图应该有一个以白色背景显示的列表选择器。
注:我不得不因为如果我使用白色背景,主题选择深色材料采用主题的colorControlHighlight颜色的波纹,这是40ffffff使用自定义的列表选择颜色,并没有显示出来。
我第一次尝试以下操作:
布局XML
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
list_selector XML
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ff0000" >
</ripple>
和列表视图行XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables" >
<ImageView
android:id="@+id/list_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/list_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我所期待看到那时候我选择一个项目,该项目被选为带有#ff0000颜色的波纹。然而,这就是我最终看到:
我所希望的是有点接近这种行为 - 但选择列表行内限制!我究竟做错了什么?
感谢, 扎克
感谢Alanv!今天的另一个很好的回应(你之前帮助过我的另一个涟漪问题!)。不胜感激。 – Zach 2014-11-20 21:05:44
什么是@ id/mask?我需要在其他地方定义它吗? – poitroae 2015-08-11 07:32:19
这应该是'@android:id/mask'。修复了代码示例。 – alanv 2015-08-11 21:25:41