2016-07-13 2 views
1

Ich habe ein XML-Layout mit edittext listview und eine fab in einem linearen Layout, die einen großen Teil auf dem Bildschirm und wenn ich Gewicht zu verlieren oder damit spiele ich bekomme ein sehr kleiner Knopf oder beschnitten.Wie passt man am besten eine benutzerdefinierte Ansicht von Floating Action Button zusammen mit Listview

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPersonName" 
    android:ems="10" 
    android:id="@+id/inputSearch" 
    android:hint="Αναζητηση" /> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="1" 
    android:layout_margin="4dp"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/listCustomers" 
     android:layout_margin="5dp" 
     android:dividerHeight="2dp" /> 
</LinearLayout> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="2" 
    android:layout_gravity="bottom|center" 
    android:gravity="right" 
    android:layout_margin="4dp"> 

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="56dp" 
     android:layout_height="56dp" 
     android:id="@+id/fab" 
     app:backgroundTint="@android:color/holo_orange_light" 
     android:layout_gravity="bottom|center" 
     android:layout_margin="10dp" 
     android:src="@drawable/ic_action_cross" /> 
</LinearLayout> 

Wie ich hier eine beste Anpassung dieser drei Elemente haben kann?

Antwort

0

Ersetzen Sie Ihr komplettes Layout mit unten:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<EditText 
    android:id="@+id/inputSearch" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:hint="Αναζητηση" 
    android:inputType="textPersonName" /> 

<ListView 
    android:id="@+id/listCustomers" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/inputSearch" 
    android:layout_margin="9dp" 
    android:dividerHeight="2dp" /> 


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="56dp" 
    android:layout_height="56dp" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_margin="14dp" 
    android:src="@drawable/ic_action_cross" 
    app:backgroundTint="@android:color/holo_orange_light" /> 
</RelativeLayout> 
+0

Ja sieht nett aus, aber fab Taste deckt Text von und Image von Listview-Elemente –

+1

Nur android hinzufügen: layout_below = "@ + id/listCustomers" zu FloatActionButton und es wird bedecke sie nicht. – Drv

Verwandte Themen