如何滚动到底在活动启动时滚动型 [英] How to scroll to bottom in a ScrollView on activity startup
问题描述
我显示了滚动型的一些数据。在活动启动(方法的onCreate)我填的是滚动型数据,并希望滚动至底部。
I am displaying some data in a ScrollView. On activity startup (method onCreate) I fill the ScrollView with data and want to scroll to the bottom.
我试图用 getScrollView()。fullScroll(ScrollView.FOCUS_DOWN)
。这工作时,我让它作为按钮点击的动作,但它并没有在onCreate方法的工作。
I tried to use getScrollView().fullScroll(ScrollView.FOCUS_DOWN)
. This works when I make it as an action on button click but it doesn't work in the onCreate method.
有什么办法如何滚动滚动型对活动启动时的底部?这意味着该视图已经滚动到底时第一次显示。
Is there any way how to scroll the ScrollView to the bottom on activity startup? That means the view is already scrolled to the bottom when first time displayed.
推荐答案
它需要做如下:
getScrollView().post(new Runnable() {
@Override
public void run() {
getScrollView().fullScroll(ScrollView.FOCUS_DOWN);
}
});
这样的看法先更新,然后滚动到新的底部。
This way the view is first updated and then scrolls to the "new" bottom.
这篇关于如何滚动到底在活动启动时滚动型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!