问题
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:
You can use parentLayout
as ScrollView
instead of RelativeLayout
and keep childLayout
as RelativeLayout
.
来源:https://stackoverflow.com/questions/12050935/scroll-a-view-and-refresh-content