Android TableLayout 将其宽度从 fill_parent 调整为 wrap_content 本身

发布于 2024-12-03 04:01:27 字数 881 浏览 2 评论 0原文

我有几个具有layout_width =“fill_parent”的TableLayout,但有时它们似乎会自行切换到layout_width =“wrap_content”,导致整个表格挤压并适合最小宽度。

受影响的表之一是:

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tbl"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:stretchColumns="*">
<TableRow>
<Button
 android:id="@+id/btn1"
 android:layout_height="fill_parent"
 android:text="@string/btn1"
 android:drawableRight="@android:drawable/ic_input_get" 
/>
<Button 
 android:id="@+id/btn2"
 android:layout_height="fill_parent" 
 android:text="@string/btn2"
 android:drawableRight="@android:drawable/ic_lock_silent_mode_off" 
/>
</TableRow>
</TableLayout>

如您所见,非常标准的东西。它一开始看起来是正确的,但如果我离开活动并返回,切换似乎是随机发生的。有什么建议吗?

I have several TableLayout's that have layout_width="fill_parent" but sometimes they seem to switch to layout_width="wrap_content" on their own, causing the entire table to squeeze and fit in minimum width.

One of the affected tables is:

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tbl"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:stretchColumns="*">
<TableRow>
<Button
 android:id="@+id/btn1"
 android:layout_height="fill_parent"
 android:text="@string/btn1"
 android:drawableRight="@android:drawable/ic_input_get" 
/>
<Button 
 android:id="@+id/btn2"
 android:layout_height="fill_parent" 
 android:text="@string/btn2"
 android:drawableRight="@android:drawable/ic_lock_silent_mode_off" 
/>
</TableRow>
</TableLayout>

As you can see, pretty standard stuff. It starts off looking right, but if I navigate away from the Activity and come back, the switch seems to happen randomly. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后来的我们 2024-12-10 04:01:27

使用以下属性:

  • android:collapseColumns
  • android:shrinkColumns
  • android:stretchColumns

要了解更多信息,请检查 此链接

Use the following properties:

  • android:collapseColumns
  • android:shrinkColumns
  • android:stretchColumns

To know more, check this link.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文