【发布时间】:2016-11-26 04:39:36
【问题描述】:
我正在尝试将Ripple 效果添加到RecyclerView 的项目。我在网上看了一下,但找不到我需要的东西。我已经尝试将android:background 属性设置为RecyclerView 本身并将其设置为"?android:selectableItemBackground",但它不起作用。:
我的父布局是这样的
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/dailyTaskList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:scrollbars="vertical" />
</LinearLayout>
适配器模板如下所示
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/txtTitle"
style="@style/kaho_panel_sub_heading_textview_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/txtDate"
style="@style/kaho_content_small_textview_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
请给我解决办法
【问题讨论】:
-
你尝试过哪个家长
android:background="?android:attr/selectableItemBackground"?
标签: android android-layout android-fragments android-recyclerview