创建一个RecyclerView后,单击某个项目时,我注意到了一些奇怪的行为。显示了涟漪效应,但之后会突出显示整个项目。有谁知道为什么RecyclerView项目会以这种方式运行以及这是否是某种错误?
RecyclerView项目布局(单行)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearlayout_listitem_singleline"
android:foreground="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/listitem_singleline_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="?android:attr/textColorPrimary" />
</LinearLayout>
RecyclerView项目布局(双行)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/relativelayout_listitem_dualline"
android:foreground="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:baselineAligned="false"
android:padding="12dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/listitem_dualline_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee"
android:textColor="?android:attr/textColorPrimary"
android:fadingEdge="horizontal" />
<TextView android:id="@+id/listitem_dualline_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@id/listitem_dualline_title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:ellipsize="marquee"
android:textColor="?android:attr/textColorSecondary"
android:layout_below="@id/listitem_dualline_title"
android:fadingEdge="horizontal" />
</RelativeLayout>