其次隐藏掉浮动按钮:
最后在页面底部增加一个布局,这个布局里面是删除和多选:
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“?attr/actionBarSize”
android:layout_alignParentBottom=“true”
android:background=“@color/white”
android:gravity=“center_vertical”
android:visibility=“@{isBatchDeletion ? View.VISIBLE : View.GONE}”>
<TextView
android:id=“@+id/tv_delete”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:drawableTop=“@mipmap/ic_delete”
android:gravity=“center”
android:text=“删除”
android:textColor=“@color/black” />
<TextView
android:id=“@+id/tv_all_selected”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:drawableTop=“@{isAllSelected ? ContextCompat.getDrawable(tvAllSelected.getContext(),R.mipmap.ic_all_selected) : ContextCompat.getDrawable(tvAllSelected.getContext(),R.mipmap.ic_all_select)}”
android:gravity=“center”
android:text=“@{isAllSelected ? 取消全选
: 全选
}”
android:textColor=“@{isAllSelected ? @color/purple_500 : @color/black}” />
图标去我的源码中拿,添加位置如下图所示:
现在是页面修改完了,还有item的布局中也需要改动,打开item_notebook.xml,增加变量数据代码:
这里你会看到我把这个item的点击事件去掉了,这部分代码我将会挪到NoteActivity中,因此这里要修改一下item_notebook.xml中的代码:
<?xml version="1.0" encoding="utf-8"?><variable
name=“notebook”
type=“com.llw.mvvm.db.bean.Notebook” />
<variable
name=“isBatchDeletion”
type=“Boolean” />
<RelativeLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_margin=“@dimen/dp_4”
android:background=“@drawable/shape_bg_white_radius_12”
android:foreground=“?attr/selectableItemBackground”
android:padding=“12dp”>
<TextView
android:id=“@+id/tv_title”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_toStartOf=“@+id/iv_check”
android:ellipsize=“end”
android:singleLine=“true”
android:text=“@{notebook.title}”
android:textColor=“@color/black”
android:textSize=“16sp” />
<TextView
android:id=“@+id/tv_content”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:layout_below=“@+id/tv_title”
android:layout_marginTop=“4dp”
android:layout_toStartOf=“@+id/iv_check”
android:ellipsize=“end”
android:maxLines=“3”
android:text=“@{notebook.content}”
android:textSize=“14sp” />
<ImageView
android:id=“@+id/iv_check”
android:layout_width=“24dp”
android:layout_height=“24dp”
android:layout_alignParentEnd=“true”
android:layout_centerVertical=“true”
android:layout_marginStart=“6dp”
android:src=“@{notebook.select ? Context