2010-11-23 8 views
0

Ich habe 4 LinearLayout s, die ich in RelativeLayout s konvertieren möchte. Mit meinem xml hier, ich habe, als mein bevorzugtes Format:Wie kann ich einfach meine LinearLayouts in RelativeLayouts umwandeln?

  • Image
  • Image
  • Textview
  • Knopf

Wie komme ich zum RelativeLayout ändern, um die ersten ImageButton immer angezeigt werden ganz oben, immer die Button ganz unten anzeigen, und die zweite ImageButton unter der erstenhaben, mit dem TextView zwischen dem 2. ImageButton und dem normalen Button?

Danke!

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:gravity="center"> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/image_view" /> 

    <TextView 
     android:text="@+id/TextView01" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/message" /> 

    <Button 
     android:layout_gravity="center_horizontal" 
     android:layout_width="fill_parent" 
     android:textStyle="bold" 
     android:id="@+id/action_button"  
     android:selectAllOnFocus="false" 
     android:layout_height="100dip" 
     android:text="Click here to Crop"/> 

</LinearLayout> 
+0

genau darunter mit etwas Polsterung ... usw. – Sapp

+0

Hast du gegoogelt? http://developer.android.com/guide/topics/ui/layout-objects.html#relativelayout – Falmarri

Antwort

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

<ImageButton android:layout_below="@+id/Button01" 
      android:id="@+id/ImageButton01"  
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_width="fill_parent"> 
</ImageButton> 
<ImageButton android:layout_below="@+id/ImageButton01" 
      android:id="@+id/ImageButton02" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent"> 
</ImageButton> 
<TextView android:layout_height="wrap_content" 
      android:id="@+id/TextView01" 
      android:text="@+id/TextView01" 
      android:layout_width="wrap_content"  
      android:layout_below="@+id/ImageButton02"> 
</TextView> 
<Button android:text="@+id/Button01" 
      android:id="@+id/Button01" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_width="fill_parent"> 
</Button> 
</RelativeLayout> 

Sie auch Vielleicht möchte ich den richtigen Begriff, um etwas oben mit etwas darunter ausgerichtet aussehen - so stelle ich die oberste Taste, um die Eltern top zu umarmen, und ich möchte die Schaltfläche unten zu sehen. here und here

1

RelativeLayouts sind sehr einfach zu erstellen, wenn Sie eine IDE verwenden, die Ihnen bei den Layoutparameteroptionen hilft.

Was Sie brauchen, sind zum Beispiel android: layout_alignParentTop = "true" und Android: layout_below = "@ id/xxxxxxxx"

Dieser Link wird Ihnen den Einstieg: http://developer.android.com/guide/topics/ui/layout-objects.html

Verwandte Themen