Java 在页面底部添加签出按钮
我正在尝试在我的Java 在页面底部添加签出按钮,java,android,xml,android-layout,layout,Java,Android,Xml,Android Layout,Layout,我正在尝试在我的RecyclerView下的页面底部显示一个“签出”按钮 我的XML文件如下所示: <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools
RecyclerView
下的页面底部显示一个“签出”按钮
我的XML文件如下所示:
<androidx.drawerlayout.widget.DrawerLayout
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"
android:background="@android:color/background_light"
android:id="@+id/drawer_layout"
tools:context=".Cart">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/main_toolbar"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Cart"
android:gravity="center"
android:fontFamily="@font/poppinsbold"
android:textSize="20dp"
android:textStyle="bold"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="555dp"
android:layout_marginBottom="500px"/>
<Button
android:id="@+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Checkout" />
</LinearLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white">
<include
layout="@layout/main_nav_drawer"/>
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
不幸的是,当我应用更改时,产品看起来很棒,但是按钮没有显示出来
我怎样才能让它出现
非常感谢。问题在于RecyclerView的layout\u marginBottom属性。500像素?!你在开玩笑吧?8dp就足够了。问题在于您的RecyclerView的layout\u marginBottom属性。500像素?!你在开玩笑吧?8dp就足够了。潜在选项:
- 根据屏幕分辨率和ConstraintLayout动态设置边距。以下是一些例子:
- 根据所需比例动态设置边距。以下是一个例子:
- 删除RecyclerView的底部边距
- 考虑更新回收视图的底部边距,将其替换为更小的
- 根据屏幕分辨率和ConstraintLayout动态设置边距。以下是一些例子:
- 根据所需比例动态设置边距。以下是一个例子:
- 删除RecyclerView的底部边距
- 考虑更新回收视图的底部边距,将其替换为更小的
- 移除
回收视图的底部填充
- 不要指定
的高度,而是使用要展开的RecyclerView
的重量,直到按下按钮RecyclerView
- 从
按钮中删除
,因为它与android:layout\u alignParentBottom=“true”
线性布局无关
- 潜在选项:
- 您需要
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/main_toolbar" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:fontFamily="@font/poppinsbold"
android:gravity="center"
android:text="@string/Cart"
android:textSize="20dp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
<Button
android:id="@+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checkout" />
</LinearLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white">
<include layout="@layout/main_nav_drawer" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
您需要
- 移除
回收视图的底部填充
- 不要指定
的高度,而是使用要展开的RecyclerView
的重量,直到按下按钮RecyclerView
- 从
按钮中删除
,因为它与android:layout\u alignParentBottom=“true”
线性布局无关
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/main_toolbar" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:fontFamily="@font/poppinsbold"
android:gravity="center"
android:text="@string/Cart"
android:textSize="20dp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
<Button
android:id="@+id/checkout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checkout" />
</LinearLayout>
<RelativeLayout
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white">
<include layout="@layout/main_nav_drawer" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
谢谢您的回答。这实际上没有解决问题,但是@Zain解决了。谢谢你的回答。这实际上并没有解决问题,但是@Zain解决了。非常感谢Zain的回答。它实际上解决了我的问题,我将在中继续努力,使布局完全符合我的要求。非常感谢Zain的回答。它实际上解决了我的问题,我将在年内努力使布局完全符合我的要求。