簡體   English   中英

單擊時使 Recycleview 項目更具交互性

[英]Make Recycleview item when clicked more interactive

我在 gmail 中有一個問題,當點擊其中一個 email 時,它顯示這個 animation 在此處輸入圖像描述

我怎樣才能將它添加到我的 recyclerview 並使我的應用程序更具交互性?

您必須為每一行使用一個布局,在此文件中,您可以添加到父布局

    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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM