动态调整 Android 表格布局的大小?
我有一个动态创建的 TableLayout
,它只包含一堆 TextViews
。问题是表格有 11 列,这通常会导致一些 TextView
延伸到屏幕一侧(尤其是在纵向模式下)。
无论如何,是否可以动态调整 TextViews 中视图的大小,直到它们全部适合屏幕?是否有办法检查特定的 TextViews 当前在屏幕上是否可见?任何人都可以想出一种合适的方法来确保所有列都显示出来吗?
处理包含大量列的 tablelayouts
的最佳方法是什么?
I have a TableLayout
that I create dynamically which simply contains a bunch of TextViews
. The problem is that the table has 11 columns which usually causes some of the TextViews
to extend off the side of the screen (especially in portrait mode).
Is there anyway to dynamically adjust the size of the view in the TextViews
until they all fit on screen? Is there anyway to check if a specific TextViews
is currently visible on the screen? Can anyone think of a decent way to ensure that all the columns get displayed?
What is the best way to handle tablelayouts
with a lot of columns?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将视图添加到
TableRow
时,您可以尝试限制视图的大小。You may try bounding the size of the View when adding them into
TableRow
.您可以创建一个作为 LinearLayout 的单行,并向此布局添加加权控件。唯一的问题是,如果您不为每行插入相同数量的控件(列),那么它们将不会对齐。
You could create a single row that is a LinearLayout and add Weighted controls to this layout. The only problem is if you do not insert the same number of controls (columns) for each row, then they will not line up.