简体   繁体   English

Scrollview在android中水平和垂直滚动表格

[英]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

  1. Use a horizontal scroll view to contain the GridView 使用水平滚动视图包含GridView
  2. Then dynamically re-size the GridView width based on the number of columns that you set for the GridView 然后根据您为GridView设置的列数动态地重新调整GridView宽度的大小
  3. 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.

相关问题 如何在Android中水平和垂直滚动ViewPager? - How to scroll ViewPager both horizontally and vertically in Android? 我们怎样才能使表格布局双向滚动(水平,垂直) - how can we make table layout to scroll both ways ( horizontally, vertically) 缩放ImageView以水平填充屏幕并在ScrollView中垂直滚动(如果需要) - Scale an ImageView to fill screen horizontally and scroll (if necessary) vertically in ScrollView Android ListView如何垂直和水平滚动? - Android ListView how to scroll vertically and horizontally ? 在Android的TouchImageView中水平和垂直滚动ImageView? - Scroll Horizontally and Vertically ImageView in TouchImageView in Android? Android将EditText设置为水平滚动而不是垂直滚动 - android setting EditText to scroll horizontally instead of vertically 如何让我的布局水平和垂直滚动? - How can I make my layout scroll both horizontally and vertically? 如何在Android中水平滚动表 - how to scroll table horizontally in android 水平和垂直滚动。 如何在代码视图中显示Java代码并水平和垂直滚动代码? - Scrolling Both horizontally and vertically . how can i show my java code in a code view and scroll my code both horizontally and vertically? 如何在Android中创建水平和垂直滚动的列表视图? - How can I create a listview that scrolls both horizontally and vertically in Android?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM