2010-12-05 68 views
0

我想創建一個擴展到整個屏幕的佈局,如果有空間的話。是否有易於使用的可擴展布局?

其實,我想顯示其標題旁邊的信息。

我發現了一些可行的方法,但我覺得它比真正的解決方案更具破壞性。

<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> 

這使我可以擴展第一列,併爲第二列留出足夠的空間。這是正確的做法嗎?

回答

0

的方式是使用RelativeLayout做的,這樣說:

<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

就是這樣。謝謝。 – Jonas 2010-12-06 20:17:39