[英]Scrollview to scroll table both horizontally and vertically in android
In my android application i am using a table inside a scrollview but am not able to scroll horizontally if the length of content is more. 在我的Android应用程序中,我在滚动视图中使用一个表,但如果内容的长度更长,则无法水平滚动。 Could you please let me know any solution for this?
你能告诉我任何解决方案吗?
Thanks in advance:) 提前致谢:)
XML layout: XML布局:
<ScrollView ...>
<HorizontalScrollView ...>
YOUR TABLE HERE
</HorizontalScrollView>
</ScrollView>
Another option is by using GridView 另一种选择是使用GridView
Lastly, multiply number of columns with the width of each columns 最后,将列数乘以每列的宽度
GridView gridView = (GridView) findViewById(R.id.grid_view); int numberOfColumns = 3; int sizeOfWidthPerColumn = 20; gridView.setNumColumns(numberOfColumns); ViewGroup.LayoutParams layoutParams = gridView.getLayoutParams(); layoutParams.width = convertDpToPixels(numberOfColumns * sizeOfWidthPerColumn, this); gridView.setLayoutParams(layoutParams);
Now I am able to scroll the GridView horizontally and vertically. 现在我可以水平和垂直滚动GridView。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.