【问题标题】:TableLayout width not settingTableLayout 宽度未设置
【发布时间】:2012-03-27 01:22:31
【问题描述】:

我正在尝试设计一个布局来保存文本视图、编辑文本和一些按钮。我的问题是,每当我设置的标题超过一定长度时,它就会消失并且不显示,而且我也遇到了按钮问题,内容并没有包裹它总是比它应该的长很多,有人知道为什么吗?

<?xml version="1.0" encoding="utf-8"?>

      <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tableLayout1"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" >

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

             <TextView
                 android:id="@+id/frst1"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:text="Title:"
                 android:textSize="15sp" />

            </TableRow>

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

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

        </TableRow>

    </TableLayout>

【问题讨论】:

    标签: android tablelayout


    【解决方案1】:

    由于android:id="@+id/frst1"android:id="@+id/btnwhichcncl" 应该是表格的第一列,由于表格的属性,两者的宽度都必须相同。

    你能解释一下你应该(希望)得到什么观点和实际问题吗?

    【讨论】:

    • 取消按钮的宽度应仅与其中的“取消”一词一样宽,而是延伸并且更长。
    • 但是你的第一行第一列是textView,如果它增加按钮也会增加,因为它是表格的同一列,
    • 如果你真的想要放弃表格的想法,或者只是用线性布局包围按钮,然后是表格行等
    【解决方案2】:

    您是否尝试将 TableLayout 宽度设置为 fill_parent?另外,尝试将行设置为 fill_parent 或 match_parent

    【讨论】:

    • 这些建议都没有帮助。
    • 另外,将按钮和文本视图设置为fill_parent。
    猜你喜欢
    • 1970-01-01
    • 2013-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 2012-03-31
    相关资源
    最近更新 更多