【发布时间】:2015-10-25 02:42:14
【问题描述】:
我正在使用RecyclerView,当我触摸RecyclerView 的项目时,我看不到任何反馈。如何实现?
我试图在用户触摸RecyclerView 行时向他们显示反馈。有点像涟漪效应。
我想知道如何在RecyclerView的特定行中实现它。
这是回收站视图的自定义行布局。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/drawer_row"
android:background="?android:attr/selectableItemBackground"
android:clickable="true">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:layout_toEndOf="@+id/navigation_image"
android:layout_toRightOf="@+id/navigation_image"
android:textSize="17sp" />
<ImageView
android:id="@+id/navigation_image"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp" />
<TextView
android:id="@+id/horizontal_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#F1F1F1" />
</RelativeLayout>
这是Activity 的布局,具有RecyclerView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/windowBackground">
<RelativeLayout
android:id="@+id/nav_header_container"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:background="@drawable/ic_drawer_header">
<ImageView
android:id="@+id/circle_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/profile_pic"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="John Doe"
android:textSize="20sp"
android:textColor="#ffffff"
android:layout_below="@+id/circle_imageview"
android:layout_alignLeft="@+id/circle_imageview"
android:layout_alignStart="@+id/circle_imageview"
android:layout_marginTop="5dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Transaction Technologies"
android:layout_below="@+id/textView"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView"
android:textColor="#ffffff"
android:layout_marginTop="5dp" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/nav_header_container" />
</RelativeLayout>
我只需要突出显示/提供用户正在触摸的行的反馈。我如何实现它?
提前致谢。
【问题讨论】:
-
RecyclerView onClick的可能重复
-
@SatyenUdeshi:甚至没有关闭
-
删除这个 android:background="@color/windowBackground"
-
那个背景是 FragmentDrawers 的整个背景。
-
你的 min-sdk 版本是多少? @Shaikh MD Ashiq
标签: android material-design android-recyclerview