2012-09-16 41 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"> 
相关问题