按钮退出屏幕android布局

按钮退出屏幕android布局,android,android-recyclerview,android-relativelayout,Android,Android Recyclerview,Android Relativelayout,我得到了这个相对论,在android studio的设计屏幕上看起来不错 但是,当我在手机上测试时,如果我减小回收器视图的大小,按钮就会从屏幕上消失。它确实会出现。你们能给我一点帮助吗?我不知道如何告诉它保持3在同一屏幕上在dp(或像素)中为视图提供宽度和高度不是正确的方法。因为并非所有设备的屏幕大小都相同。Android Studio上的“设计”选项卡以像素手机显示布局,像素手机的高度大于手机。所以,你在手机上看不到那个按钮 我在你的按钮上添加了一行,删除了另一行 补充如下: andro

我得到了这个相对论,在android studio的设计屏幕上看起来不错



但是,当我在手机上测试时,如果我减小回收器视图的大小,按钮就会从屏幕上消失。它确实会出现。你们能给我一点帮助吗?我不知道如何告诉它保持3在同一屏幕上

在dp(或像素)中为
视图
提供宽度和高度不是正确的方法。因为并非所有设备的屏幕大小都相同。Android Studio上的“设计”选项卡以像素手机显示布局,像素手机的高度大于手机。所以,你在手机上看不到那个按钮

我在你的按钮上添加了一行,删除了另一行

补充如下:

android:layout_alignParentBottom="true"
删除此项:

android:layout_below="@+id/txtcartprod"
RecyclerView
的高度更改为
match\u parent
(使其取决于屏幕大小):

增加了这一行:

android:layout_above= "@id/btn_placeorder"
最终版本

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="8dp"
    tools:context="com.checking.movi.movioperations.CartItems">


    <TextView
        android:id="@+id/txtcartprod"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Productos seleccionados:"
        />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_cart"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above= "@id/btn_placeorder"
        android:layout_below="@+id/txtcartprod"
        />

    <Button
        android:id="@+id/btn_placeorder"
        style="?android:attr/buttonStyleSmall"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/mybutton"
        android:text="Continuar"
        android:textColor="#ffffff" />

</RelativeLayout>


我希望你理解我所做的所有改变。如果您有困难,请随时在评论中提问。

使用
android:layout\u alignParentBottom=“true”
作为按钮。使用
android:layout\u height=“wrap\u content”
android:layout\u over=”“
查看回收者视图。好的,ashu,我回来后会试试,让你知道结果谢谢你好,ashu,tuqay的答案和你的一样,所以效果很好Hanks tuqay肯定会试试的谢谢tuqay,效果很好,你是对的,我不应该把固定的像素大小,因为它取决于屏幕大小,你建议的更改,现在按钮出现了吗
android:layout_above= "@id/btn_placeorder"
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="8dp"
    tools:context="com.checking.movi.movioperations.CartItems">


    <TextView
        android:id="@+id/txtcartprod"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Productos seleccionados:"
        />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_cart"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above= "@id/btn_placeorder"
        android:layout_below="@+id/txtcartprod"
        />

    <Button
        android:id="@+id/btn_placeorder"
        style="?android:attr/buttonStyleSmall"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/mybutton"
        android:text="Continuar"
        android:textColor="#ffffff" />

</RelativeLayout>