2012-02-16 9 views
3

私は約3行のTableLayoutを持っています。私は最後の行の高さをビューの残りの部分を埋めるために取得したいと思いますが、Androidのレイアウトを扱うことは無駄を教えてくれるので大したことはありません。これは私がこれまで持っているものされていますTableLayoutの最後の行を展開します

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:stretchColumns="*" > 

    <TableRow android:padding="5dip"> 
      <TextView 
      android:text="Row 1" 
      /> 
    </TableRow> 
    <TableRow android:padding="5dip"> 
     <TextView 
      android:text="Row 2" 
      /> 
    </TableRow> 
    <TableRow android:padding="5dip" android:layout_height="fill_parent"> 
     <TextView 
      android:text="Row 3" 
      /> 
    </TableRow> 
</TableLayout> 

答えて

1

もっと使いやすいLinearLayoutを使用してください。以下の0dpは意図的です。

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

    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dip" android:orientation="horizontal"> 
      <TextView 
      android:text="Row 1" 
      /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="5dip" android:orientation="horizontal"> 
     <TextView 
      android:text="Row 2" 
      /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" android:padding="5dip" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal"> 
     <TextView 
      android:text="Row 3" 
      /> 
    </LinearLayout> 
</LinearLayout> 
0

あなたは他の2行のレイアウトの高さを設定したり、フィル親としてコンテンツと最後の1をラップするためにそれを設定してみてくださいましたか?

2

解決方法:

そのためには、レイアウトにウェイトを使用する必要があります。

は、XMLコードの下を参照してください:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    > 

    <TableRow android:padding="5dip"> 
     <TextView android:text="Row 1" /> 
    </TableRow> 
    <TableRow android:padding="5dip"> 
     <TextView android:text="Row 2" /> 
    </TableRow> 
    <TableRow android:padding="5dip" android:layout_weight="1"> 
     <TextView android:text="Row 3" /> 
    </TableRow> 
</TableLayout> 

をお楽しみください。 :)

+0

これは正解とマークする必要があります –

+0

@RaduSimionescuご意見ありがとうございます。 –

関連する問題