Scrolling View and update content

I am using the following user interface:

  • Parent relative parentLayout layout with dimensions 800x600 (width x height)

  • The second relative layout is childLayout , which is a child of the parent layout. It has dimensions of 800x1000, i.e. more than the parent layout.

     parentLayout.addView(childLayout); 

My goal: scrolling childLayout with childLayout.scrollTo(x,y) .

When I use childLayout.scrollTo(x,y) , Android scrolls through childLayout but does not update (redraw) it. The effect is that childLayout cut to the same sizes as parentLayout .

Unfortunately, the following solutions do not solve the problem:

 childLayout.scrollTo(x,y); childLayout.invalidate(); childLayout.requestLayout(); 

Any ideas how to solve this problem?

+6
source share
1 answer

You can use parentLayout as ScrollView instead of RelativeLayout and save childLayout as RelativeLayout .

-1
source

Source: https://habr.com/ru/post/923363/


All Articles