我正在使用 RecyclerView + GridLayout(3 列)。现在,为了让网格的每个方格更“响应”,我希望每个方格都显示某种分隔线,并且用户点击的每个方格内都会产生涟漪效应。
编辑:我添加了android:foreground="?attr/selectableItemBackground",但没有任何反应。这是现在的单项 xml 代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="6dip" >
<ImageView
android:foreground="?attr/selectableItemBackground"
android:id="@+id/icon"
android:layout_width="128dp"
android:layout_height="118dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginTop="12dp"
android:contentDescription="TODO"
android:src="@drawable/ic_launcher_background" />
</RelativeLayout>
这是修复后当前的工作方式,添加后:
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"


