我正在使用以下xml drawable作为我的recyclerview列表项的背景。Andriod Recycler查看纹波效果不起作用
touch_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true"
android:drawable="@color/green_text_500"/>
<!-- Default, "just hangin' out" state. The base state also
implements the ripple effect. -->
<item android:drawable="@drawable/touch_selector_base" />
</selector>
touch_selector_base.xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/light_grey">
<item android:id="@android:id/mask" android:drawable="@color/light_grey" />
<item android:drawable="@color/dark_grey"/>
</ripple>
在我使用的touch_selector.xml在我list_item_quote.xml如下列表项
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="86dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clickable="true"
android:focusable="true"
android:background="@drawable/touch_selector"
>
// layout
</LinearLayout>
同样我有另一个XML抽拉touch_selector_dark.xml和touch_selector_base_dark.xml
以我回收 - 视图 - 适配器我基于索引这两个可绘之间交替。对于偶数索引,我使用较深的drawable,对于奇数索引,我使用较亮的背景来产生交替效果。但问题是涟漪效应不起作用。
这里是颜色:
light_grey =#5b5b5b
dark_grey =#212121
green_text_500 =#37863a
试试这个android:background =“?attr/selectableItemBackgroundBorderless”为您的适配器父级布局背景 – PLP
试试这里的解决方案http://stackoverflow.com/questions/28636377/ripple-effect-over-a-recyclerview-item-含ImageView的 – Raghavendra