Android 使用RecyclerView将按钮放在屏幕的底部中央
我有回收视图和按钮。按钮在recyclerView下面。我想把按钮放在我的屏幕的底部中央。这在任何设备中都不会改变。因为在某些设备中,按钮会消失 我的XmlAndroid 使用RecyclerView将按钮放在屏幕的底部中央,android,xml,button,android-recyclerview,Android,Xml,Button,Android Recyclerview,我有回收视图和按钮。按钮在recyclerView下面。我想把按钮放在我的屏幕的底部中央。这在任何设备中都不会改变。因为在某些设备中,按钮会消失 我的Xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" androi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#33DADADA"
android:fitsSystemWindows="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<include
android:id="@+id/app_bar"
layout="@layout/app_toolbar"></include>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#4dabf5"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distribution Channel "
android:textSize="18sp" />
<Spinner
android:id="@+id/selectDistribChannel"
android:layout_width="150dp"
android:layout_height="wrap_content"></Spinner>
</LinearLayout>
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView"
android:layout_width="320dp"
android:layout_height="35dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/rounded_edittext"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:hint="Search Products"
android:singleLine="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/selectedItemRecyclerView"
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#33DADADA"
android:padding="5dp">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|bottom">
<Button
android:id="@+id/bAdd"
android:layout_width="250dp"
android:layout_height="48dp"
android:text="Send"
android:textColor="@color/btn_login" />
</LinearLayout>
</LinearLayout>
试试这个(替换为Relativelayout)——
让我知道这是否有效
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.RecyclerView
android:id="@+id/selectedItemRecyclerView"
android:layout_above="@id/button"
android:layout_weight=1
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#33DADADA"
android:padding="5dp">
</android.support.v7.widget.RecyclerView>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:text="write your text"
android:textColor="@color/colorPrimary" />
</RelativeLayout>
是的,有些什么好。仍然不适合屏幕。从按钮布局中获取更多高度。因此,回收站的高度会降低
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.RecyclerView
android:id="@+id/selectedItemRecyclerView"
android:layout_above="@id/button"
android:layout_weight=1
android:layout_width="match_parent"
android:layout_height="350dp"
android:background="#33DADADA"
android:padding="5dp">
</android.support.v7.widget.RecyclerView>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:text="write your text"
android:textColor="@color/colorPrimary" />
</RelativeLayout>