繁体   English   中英

如何在屏幕底部添加具有回收器视图的按钮。 这样按钮就不会隐藏回收器视图的最后一个元素

[英]How can I add button at the bottom of the screen having a recycler View. so that the button don't hide the last element of recycler view

我想添加一个按钮,该按钮仅在选中回收站视图的任何项目时才会显示,并在取消选中时隐藏它。 该按钮不应隐藏回收站视图的最后一个元素。 我尝试了这段代码,但是当我使按钮可见(通过选择回收器视图的一个项目)并滚动到回收器视图的底部时,它与最后一个元素重叠。

<?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>

尝试这个,

    <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" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM