Scroll a View and refresh content

流过昼夜 提交于 2020-01-03 09:07:12

问题


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

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