2016-05-09 8 views
1

Ich habe RecyclerView und Button. Button kommt unter die RecyclerView. Ich möchte den Button in der unteren Mitte des Bildschirms auf meinem Bildschirm platzieren. Das sollte sich bei keinem Gerät ändern. Weil in einigen Geräten Knopf verschwinden.Setzen Sie den Knopf auf der unteren Mitte des Bildschirms mit dem RecyclerView

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

Antwort

2

Versuchen Sie, diese (ersetzen durch Relativelayout) -

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <Button 
      android:id="@+id/bAdd" 
      android:layout_width="250dp" 
      android:layout_height="48dp" 
      android:layout_alignParentBottom="true" 
      android:text="Send" 
      android:textColor="@color/btn_login" /> 

    </RelativeLayout> 

Lassen Sie mich wissen, ob dies

+0

ja, etwas, was gut funktioniert. immer noch nicht auf den Bildschirm passen. mehr Höhe aus dem Tastenlayout. Recyclerview wird also weniger hoch –

1
<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> 
Verwandte Themen