У меня есть recylcerview с границами, и я хочу добавить анимацию только в область с границами, как мне ее добавить? Я хочу добавить android:foreground="?attr/selectableItemBackground"
так, чтобы при щелчке по строке анимация отображалась только в ограниченной области, а не во всей строке
Recycler View
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/recycler_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
Элемент строки
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pokedex_row"
android:padding="10sp"
android:clickable="true"
android:focusable="true"
android:background="@drawable/card_background"
android:elevation="12dp"
android:foreground="?attr/selectableItemBackground"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pokedex_row_text_view"
android:layout_margin="10sp"
/>
</LinearLayout>
фон строки
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="8dp"
android:right="3dp"
android:top="8dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#CBAAAAAA"
android:width="1dp"/>
<corners android:radius="5dp" />
</shape>
</item>
<item
android:left="5dp"
android:right="5dp"
android:top="5dp"
android:bottom="5dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>