2010-12-05 64 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