本文介绍了滚动查看并刷新内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的用户界面:


  • 一个父相对布局 parentLayout 与尺寸800×600(宽x高)

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

第二相对布局 childLayout ,这是父布局的孩子。
它具有尺寸800x1000,即,它是比母体布局更大

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);


我的目标:滚动 childLayout 使用 childLayout.scrollTo(X,Y)

当我使用 childLayout.scrollTo(X,Y),Android的滚动 childLayout ,但不会刷新(重绘)吧。效果是, childLayout 切成相同尺寸 parentLayout

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?

推荐答案

您可以使用 parentLayout 滚动型代替的 RelativeLayout的并保持 childLayout RelativeLayout的

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

这篇关于滚动查看并刷新内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 22:48