2012-07-24 7 views
7

Tôi có bố cục tuyến tính chỉ với một TableLayout đơn trong đó. Bố cục bảng tiếp tục có hai hàng với hai cột. Hàng đầu tiên của bảng có hai hình ảnh. Hàng Bảng Thứ hai có hai nút.Android Bảng Chiều cao chiều cao không lấp đầy toàn bộ màn hình

Nhưng điều này không hiển thị trên màn hình hoàn chỉnh, thay vì chỉ hiển thị trong nửa đầu hoặc có thể phụ thuộc vào chiều cao hình ảnh. Cả hai hình ảnh thực sự là cùng một tệp, nhưng được hiển thị với Độ rộng khác nhau. Trợ giúp xin vui lòng ... đây là file Layout

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical"> 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:stretchColumns="*"> 

     <TableRow 
      android:layout_height="fill_parent"> 

      <ImageView 
       android:id="@+id/tp_image" 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_weight="0.9" 
       android:scaleType="fitXY" 
       android:src="@drawable/images" /> 

      <ImageView 
       android:id="@+id/s_image" 
       android:src="@drawable/images" 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:scaleType="fitXY" 
       android:layout_weight="0.1" 
       /> 
     </TableRow> 
     <TableRow > 
      <Button 
       android:id="@+id/button_LC" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/button_LC"/> 
      <Button 
       android:id="@+id/button_RC" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/button_RC"/> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 

Trả lời

13

thiết

<TableRow 
    android:layout_height="0dp" 
    android:layout_weight="1" > 

cho cả hàng bảng hoặc chỉ để hàng đầu tiên.

+0

hoạt động như phép thuật sau khi thực hiện việc này cho TableRow đầu tiên ... nhưng làm thế nào ??? Các thuộc tính này làm gì trong nền? – Anjanu

+1

[Bố cục trọng lượng được giải thích] (http://stackoverflow.com/questions/3995825/what-does-androidlayout-weight-mean) –