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. Could y开发者_Python百科ou please let me know any solution for this?
Thanks in advance:)
XML layout:
<ScrollView ...>
<HorizontalScrollView ...>
YOUR TABLE HERE
</HorizontalScrollView>
</ScrollView>
Another option is by using GridView
- Use a horizontal scroll view to contain the GridView
- Then dynamically re-size the GridView width based on the number of columns that you set for the 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.
精彩评论