2010-12-05 7 views
0

Ich versuche ein Layout zu erstellen, das sich auf den gesamten Bildschirm erstreckt, wenn Platz vorhanden ist.Gibt es ein einfach zu verwendendes erweiterbares Layout?

Eigentlich möchte ich Informationen neben seinem Titel anzeigen.

Ich fand etwas, das funktioniert, aber ich denke, es ist mehr ein Hack als eine echte Lösung.

<TableLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:id="@+id/resort_infos" 
    android:stretchColumns="0"> 
    <TableRow android:background="#0b66ad" android:padding="3dip"> 
     <TextView android:id="@+id/openSlopesKmTitle" 
      android:text="@string/slopes_km" android:textColor="#EEE" /> 
     <TextView android:id="@+id/slopes" android:layout_width="fill_parent" 
      android:layout_height="wrap_content" android:gravity="right" 
      android:textColor="#EEE" android:paddingRight="15dip" /> 
    </TableRow> 
</TableLayout> 

Dies ermöglicht mir, die erste Spalte zu erweitern und genügend Platz für die zweite Spalte zu lassen. Ist es der richtige Weg?

Antwort

0

Die Art und Weise, es zu tun ist mit RelativeLayout, auf diese Weise:

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:id="@+id/slopes" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:textColor="#EEE" 
     android:paddingRight="15dip" /> 
    <TextView 
     android:id="@+id/openSlopesKmTitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_toLeftOf="@id/slopes" 
     android:text="@string/slopes_km" 
     android:textColor="#EEE"/> 
</RelativeLayout> 
+0

das war es. Vielen Dank. – Jonas