添加视图后如何立即滚动到末尾?
How to scroll to the end immediately after adding view?
当我向 HorizontalScrollView 中的 LinearLayout 添加动态视图时,我尝试立即滚动到末尾(右),它的行为就像视图还不存在一样,并从结尾。 xamarin android to update/refresh有什么技巧?在 Windows Phone 中,在滚动视图上调用的 UpdateLayout 完成了这项工作,但我尝试了 Invalidate 和 ForceLayout 的一些组合,但没有成功。例如,当我把
await Task.Delay(100);
在滚动代码之前,它完美地滚动了。但是没有它,滚动功能就看不到新添加的视图。
这是我的滚动代码:
scrollMoves.FullScroll(FocusSearchDirection.Right);
试试这个
fragement_card_info_scrollview.fullScroll(View.FOCUS_RIGHT);
在 java 中有一个名为 yourView.post()
的方法,它接受一个 runnable。将滚动放在 post()
方法中。喜欢:
yourView.post(new Runnable() {
@Override
public void run() {
//Here goes the scrolling code
}
});
当我向 HorizontalScrollView 中的 LinearLayout 添加动态视图时,我尝试立即滚动到末尾(右),它的行为就像视图还不存在一样,并从结尾。 xamarin android to update/refresh有什么技巧?在 Windows Phone 中,在滚动视图上调用的 UpdateLayout 完成了这项工作,但我尝试了 Invalidate 和 ForceLayout 的一些组合,但没有成功。例如,当我把
await Task.Delay(100);
在滚动代码之前,它完美地滚动了。但是没有它,滚动功能就看不到新添加的视图。
这是我的滚动代码:
scrollMoves.FullScroll(FocusSearchDirection.Right);
试试这个
fragement_card_info_scrollview.fullScroll(View.FOCUS_RIGHT);
在 java 中有一个名为 yourView.post()
的方法,它接受一个 runnable。将滚动放在 post()
方法中。喜欢:
yourView.post(new Runnable() {
@Override
public void run() {
//Here goes the scrolling code
}
});