语言无法具体表达做出来的效果,这里请读者先看一下演示
左滑删除功能演示
第一步,布局文件代码
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView android:id="@+id/card_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:clickable="true"
android:foreground="?attr/selectableItemBackground"
app:cardBackgroundColor="@color/colorAccent"
app:cardCornerRadius="2dp"
app:cardElevation="4dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="140dp">
<ImageView
android:id="@+id/item_img"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginEnd="21dp"
android:background="@drawable/ic_22"
android:scaleType="center" />
<RelativeLayout
android:layout_marginLeft="20dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingBottom="5dp">
<TextView
android:text="nihao"
android:layout_marginTop="5dp"
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:textColor="@color/color_white"
android:textSize="16sp"
/>
<TextView
android:text="nihao"
android:layout_marginTop="5dp"
android:id="@+id/tv_sex"