2017-03-03 6 views
0

Ich erstelle einen benutzerdefinierten Dialog, aber nicht alle Schaltflächen passen gut. Ich weiß nicht, warum passiert, auf Vorschau in Android Studio ist gut aussehen, aber im Telefon ist nicht gut aussehen.Java android benutzerdefinierte Dialogfeld Schaltfläche passt nicht

Das ist mein Layout:

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


    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Wybierz grupę:" 
     android:textColor="#000000" 
     /> 


    <Spinner 
     android:id="@+id/fd_valSp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/text" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginTop="20dp" /> 

    <LinearLayout 
     android:layout_below="@+id/fd_valSp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 


     <Button android:id="@+id/cancel_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/cancel" /> 


     <Button android:id="@+id/add_group_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/add_new_group" 
      /> 

     <Button android:id="@+id/add" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/add" 
      /> 

    </LinearLayout> 

</RelativeLayout> 

enter image description here

Antwort

0

Einsatz unter XML

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


    <TextView 
     android:layout_alignParentTop="true" 
     android:id="@+id/text" 
     android:gravity="center" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Wybierz grupę:" 
     android:textColor="#000000" /> 


    <Spinner 

     android:id="@+id/fd_valSp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_below="@+id/text" 
     android:layout_marginTop="20dp" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/fd_valSp" 
     android:weightSum="10" 
     android:orientation="horizontal"> 


     <Button 
      android:id="@+id/cancel_button" 
      android:layout_width="0dp" 
      android:layout_weight="2.5" 
      android:layout_height="wrap_content" 
      android:text="@string/cancel" /> 


     <Button 
      android:id="@+id/add_group_button" 
      android:layout_width="0dp" 
      android:layout_weight="5" 
      android:layout_height="wrap_content" 
      android:text="@string/add_new_group" /> 

     <Button 
      android:id="@+id/add" 
      android:layout_width="0dp" 
      android:layout_weight="2.5" 
      android:layout_height="wrap_content" 
      android:text="@string/add" /> 

    </LinearLayout> 

</RelativeLayout> 
0

Sie layout_weight mit Linear-Layout wie 0,3 verwenden können, 0.4,0.3 dies Tasten passen drin.

Oder Sie können 3 Tasten auch vertikal anzeigen, wenn die Zeichenfolge lang ist.

0

Versuchen Sie, Gewicht Eigenschaft mit linearem Layout zu verwenden, wird es für Sie arbeiten.

Verwandte Themen