Android, Horizontal and Vertical Scroll for GridLayout

你说的曾经没有我的故事 提交于 2019-12-04 05:26:51

Well I found the solution

It seems like the android ScrollView works as a VerticalScrollView and only that (the name is not so intuitive as HorizontalScrollView).

So to make something scrollable vertically and horizontally, you need to nest a (Vertical)ScrollView inside a HorizontalScrollView, or the other way around, like this

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <HorizontalScrollView
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

            <!-- Your content here -->

     </HorizontalScrollView>
</ScrollView>

The nested HorizontalScrollView / ScrollView will not allow you to scroll both directions at the same time. I had this problem and created a custom component for that, here is the link if it can help anybody :

https://gist.github.com/androidseb/9902093

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!