I want to add the button which will only be shown at when any item of recycler view is checked and hide it when uncheck. The button should not hide the last element of recycler view. I tried this code but when I make the button visible (by selecting an item of recycler view) and scroll to the bottom of the recycler view it overlap the last element.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".activity.RestaurantMenuActivity">
<RelativeLayout
android:id="@+id/menu_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:elevation="6dp">
<LinearLayout
android:id="@+id/header_ll_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_restaurant_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="8.2"
android:gravity="center_vertical"
android:paddingStart="20dp"
android:paddingTop="10dp"
android:paddingEnd="10dp"
android:paddingBottom="6dp"
android:text="Sample restaurant name"
android:textColor="@color/Black"
android:textSize="20sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/img_restaurant_fav"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_weight="1.8"
android:padding="6dp"
android:src="@drawable/ic_fav" />
</LinearLayout>
<TextView
android:id="@+id/tv_menu_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/header_ll_layout"
android:layout_alignParentStart="true"
android:layout_marginStart="1dp"
android:layout_marginTop="0dp"
android:drawableStart="@drawable/ic_list"
android:gravity="center_vertical"
android:paddingStart="20dp"
android:paddingTop="6dp"
android:paddingEnd="16dp"
android:paddingBottom="6dp"
android:text="@string/menu"
android:textColor="@color/Black"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="@+id/bt_goto_cart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:backgroundTint="@color/green"
android:gravity="center"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:text="SampleGOTOcart"
android:textColor="@color/white"
android:textSize="15sp"
android:visibility="invisible"
tools:visibility="visible" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/menu_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tv_menu_title"
android:background="@color/white" />
</RelativeLayout>
</RelativeLayout>
Try this,
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/menu_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bt_goto_cart"
android:layout_below="@id/tv_menu_title"
android:background="@color/white" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.