Search code examples
androidandroid-scrollview

How do I get a ScrollView to support very large content?


I've noticed that setScrollX() and setScrollY() of Scroll Views in Android take an integer as parameter, but when given parameters bigger than 10 237 080 they scroll to 10 237 080 and don't continue. From there I start scrolling and it does work, but the the scrollbar is at the end of the screen (it shouldn't, there is still content) and the end corner animation of the scrollview is showing up (again it shouldn't, there is content). So I just did this android:scrollbars="none" and android:overScrollMode="never", but it doesn't solve my problem, because I stil want the scroll to go at setScrollX(50000000) for example. How do I get pass these limitations? Does anyone know? And btw I am using:

ScrollView_X.post(new Runnable() {
        public void run() {
            ScrollView_X.setScrollX(50000000);
        }
    });

Here is a little video for more detailed view: https://youtu.be/dggGx40p6hc (don't mind the Y offset, it's something i forgot to remove from the code for the video).

EDIT: I've tried many things the past day and I've come to a conclusion that scrollviews can support content up to (14 218*width of your screen in px) in px without any problems (720p display = 10 236 960 pixels/ 1080p = 15 355 440 pixels). Same goes for the height, but I didn't test with 14 218*height, instead I used width. How does that work for different screen sizes I have no idea, but these are safe values. If anyone can tell me what's up with these views, please enlighten me!


Solution

  • I've tried many things the past day and I've come to a conclusion that scrollviews can support content up to (14 218*width of your screen in px) in px without any problems (720p display = 10 236 960 pixels/ 1080p = 15 355 440 pixels). Same goes for the height, but I didn't test with 14 218*height, instead I used width. How does that work for different screen sizes I have no idea, but these are safe values. If anyone can tell me what's up with these views, please enlighten me!