【问题标题】:TableLayout button bigger than screenTableLayout 按钮比屏幕大
【发布时间】:2012-09-19 09:06:20
【问题描述】:

我正在使用 TableLayout 进行设置布局。我所有的行都填满了屏幕。而且因为图像更容易理解,所以这里的情况:

这里是部分Layout代码(我没有放所有的,因为行很多,都一样):

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:isScrollContainer="true"
        android:orientation="vertical"
        android:scrollbarAlwaysDrawVerticalTrack="true"
        android:scrollbars="vertical">

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/textIpBox"
                android:text="@string/ipAddress" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <View
                android:id="@+id/dividerIpbox"
                android:background="@android:drawable/divider_horizontal_dim_dark" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:id="@+id/textPortSend"
                android:text="@string/sendPort" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <EditText
                android:id="@+id/entryPortSend"
                android:inputType="number"
                android:background="@android:drawable/editbox_background" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <View
                android:id="@+id/dividerPortSend"
                android:background="@android:drawable/divider_horizontal_dim_dark" />

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <Spinner
                android:id="@+id/spinner"
                android:prompt="@string/home_page" />

        </TableRow>

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <TextView
                android:id="@+id/textCurrentWifi"
                android:text="@string/currentWifi" />

        </TableRow> 

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="5dp" >

            <Button
                android:id="@+id/buttonSave"
                android:text="@string/validate" />
        </TableRow>

    </TableLayout >

</ScrollView>

我肯定在android:layout_width="fill_parent" 周围遗漏了一些东西,但我看不到是什么。

当我所有的 layout_width 都设置为 fill_parent 时,我不太明白为什么它不起作用

【问题讨论】:

    标签: android-layout


    【解决方案1】:

    我不同意。这可能已经解决了问题,但是将线性布局更改为表格布局并不能修复表格布局。
    试试

    android:stretchColumns = "1,2,3"
    android:shrinkColumns = "1,2,3"
    

    这将告诉应用应扩大/缩小哪些列以适应屏幕。

    【讨论】:

      【解决方案2】:

      我找到了问题,尝试将您的 TableLayout 更改为 LinearLayout

      <LinearLayout 
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:isScrollContainer="true"
          android:orientation="vertical"
          android:scrollbarAlwaysDrawVerticalTrack="true"
          android:scrollbars="vertical">
      

      【讨论】:

      • 不错!那是问题!现在我的标签留在盒子里!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      • 2022-01-20
      • 2017-12-02
      • 1970-01-01
      相关资源
      最近更新 更多