如何在android中制作全屏表格
我正在开发一个 Android 程序,我想制作一个 3x7(3 列,7 行)表格,其中每个单元格都有一个按钮。
我尝试过使用 tableLayout,但每次表格的宽度总是太短或太长,这意味着要么有空白,要么按钮脱离页面。我对高度没有问题,只是宽度有问题。
这个问题也可以通过像 java 中的 GridLayout 这样的布局轻松解决。 Android 中有类似的吗?
任何想法都将不胜感激。
I am working on a program for Android, and I want to make a 3x7 (3 columns, 7 rows) table, where each cell holds a button.
I have tried using tableLayout, but every time the width of the tables are always too short or too long, meaning that there is either blank space or the buttons go off of the page. I am not having a problem with the height, just the width.
This problem could also be solved easily with a layout like GridLayout from java. Is there an equivalent to that in Android?
any ideas are greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用带有权重的线性布局。
尝试一下,我认为就可以了,虽然可能需要一些工作,但它应该让你指明正确的方向。
You have to use linear layouts with weights.
Try this out, I think that does it, though it might take a little work, but it should get you pointed in the right direction.
也许在按钮上设置 android:layout_width 固定大小“185dp”
maybe set android:layout_width on you button in fix size "185dp"