Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用RecyclerView将按钮放在屏幕的底部中央_Android_Xml_Button_Android Recyclerview - Fatal编程技术网

Android 使用RecyclerView将按钮放在屏幕的底部中央

Android 使用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

我有回收视图和按钮。按钮在recyclerView下面。我想把按钮放在我的屏幕的底部中央。这在任何设备中都不会改变。因为在某些设备中,按钮会消失

我的Xml

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