2017-02-11 5 views
0

Ich möchte 3 kreisförmige Schaltflächen horizontal mit gleichen Rändern haben. Ich habe versucht, programmgesteuert zu setzen, aber ich bekomme NPE, da die Ansicht nicht gezeichnet wurde.Platziere drei Kreise in einem LinearLayout, um die gleiche Menge an Platz einzunehmen.

Wie kann ich es in Layout-Datei tun? Ich habe es unten versucht, aber es ist kein Kreis.

Place 3 buttons in a LinearLayout to occupy equal amount of space

Bitte helfen.

+0

http://stackoverflow.com/questions/17823582/circular-buttons-in-linearlayoutvertical hatte die Antwort für mich – GJain

Antwort

0

Sie können dies versuchen.

circle.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 
    <corners android:radius="10dip"/> 
    <stroke android:color="#FF0000" android:width="5dip"/> 
    <solid android:color="#FF0000"/> 
</shape> 

Setzen Sie diese in den Ordner ziehbar und setzen diese als Hintergrund Ihrer Tasten (hinzugefügt wie in der akzeptierte Antwort des Link).

this helps

1

Verwenden ähnliche

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 
    </FrameLayout> 

    <FrameLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/> 
    </FrameLayout> 
</LinearLayout> 

Bewerben Art Ihrem Tasten

Verwandte Themen