Android TableLayout宽度(Android TableLayout Width)

编程入门 行业动态 更新时间:2024-10-28 02:28:16
Android TableLayout宽度(Android TableLayout Width)

我有一个两列ColumnLayout作为滚动视图的唯一孩子。 第一列包含TextViews('标签'),第二列包含EditText / Spinner / DateWidget等('values')。 尽管我已经为TableLayout,TableRow和所有小部件(在'values'列中)指定了android:layout_width =“fill_parent”。

活动创建时,屏幕看起来很完美。 但是,如果在EditText中输入一个非常长的值,那么“值”列将超出可见屏幕区域。

我如何解决这个问题?

谢谢

I have a two column TableLayout as the only child of a scroll view. The first column contains TextViews ('labels') and the second column contains EditText/Spinner/DateWidget etc ('values'). Even though I have have specified android:layout_width="fill_parent" for TableLayout, TableRow & all widgets (in 'values' column).

The screen looks perfect when the activity is created. However, when one types a really long value in the EditText, the 'values' column goes beyond the visible screen area.

How do I tackle this?

最满意答案

您可能想要通过使用权重来定义列的大小。 因此,您将定义表格布局高度以填充父级,但对于每个列,您应将宽度设置为“0px”,并将权重设置为您希望列跨度的百分比。 因此,假设您希望第一列为屏幕宽度的30%,您将其权重设置为“0.3”,将第二列设置为“0.7”。

试试看看是否有效。

You may want to define the sizes of the columns by using a weight. So you will define the table layout height to fill parent but for each column you should set the width to "0px" and the weight to the percentage you want the column to span. So assuming you want the first column to be 30% of the screen width you set it's weight to "0.3" and the second column to "0.7".

Try it and see if that works.

更多推荐

本文发布于:2023-07-28 01:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1298336.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:宽度   Android   TableLayout   Width

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!