[英]Make Recycleview item when clicked more interactive
您必須為每一行使用一個布局,在此文件中,您可以添加到父布局
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"
例如:
Application_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/applicationLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:gravity="center_vertical"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground">
<ImageView
android:id="@+id/applicationIcon"
android:layout_width="50dp"
android:layout_height="50dp"/>
<TextView
android:id="@+id/applicationName"
android:layout_width="wrap_content"
android:layout_margin="15dp"
android:layout_height="wrap_content"
android:text="Application name"
android:textSize="20sp"/>
</LinearLayout>
當用戶觸摸它時,這將使該行具有 animation。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.