【问题标题】:Edittext not filling parentEdittext不填充父级
【发布时间】:2012-09-16 22:25:39
【问题描述】:

所以我正在尝试使用我的片段的表格布局制作带有提交按钮的教科书,但问题是教科书正在变成按钮的大小。它没有填充宽度

<?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>

我做错了什么?

【问题讨论】:

    标签: android xml styles


    【解决方案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">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-14
      • 1970-01-01
      相关资源
      最近更新 更多