Scroll a View and refresh content

2.5k Views Asked by At

I use the following user interface:

  • A parent relative layout parentLayout with the dimensions 800x600 (width x height)

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

    parentLayout.addView(childLayout);
    

My goal: Scrolling childLayout by using childLayout.scrollTo(x,y).

When I use childLayout.scrollTo(x,y), Android scrolls childLayout but doesn't refresh (redraw) it. The effect is, that childLayout is cut to the same dimensions as parentLayout.

Unfortunately, the following solutions don't solve the problem:

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

Any ideas how to solve this problem?

1

There are 1 best solutions below

1
On

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