Solution 1 :
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" />
Problem :
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>
Comments
Comment posted by Vijay
This works like perfectly for me only thing I need to do is keep the Button(bt_goto_cart) visibility to GONE.