2012-09-16 47 views
0

所以我試圖用一個提交按鈕使用我的片段的表格佈局的教科書,但問題是教科書正在成爲按鈕的大小。它沒有填滿寬度Edittext not fill parent

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

     <TableRow 
      android:id="@+id/tableRow1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

      <EditText 
       android:id="@+id/editText1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:inputType="textUri" /> 

     </TableRow> 

     <TableRow 
      android:id="@+id/tableRow3" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

      <Button 
       android:id="@+id/button_as" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="As" /> 

     </TableRow> 

</TableLayout> 

我做錯了什麼?

回答

1

當前,整個列的寬度由後續Button的寬度定義。這是因爲Button是列中最寬的。

在您的TableLayout元素中,您希望通過聲明android:stretchColumns將第一列(索引0)標記爲可拉伸。

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:stretchColumns="0"> 
相關問題