我有一个两列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.
更多推荐
发布评论