[英]Scroll View doesn't scroll to top - Android
I am trying to scroll to the top of my ScrollView
, and I am using the below and both types it works a little over 50% the other time sit just stays where it is 我正在尝试滚动到我的
ScrollView
的顶部,我正在使用下面的两种类型,它的工作时间超过50%,而另一次只是停留在它的位置
private void focusOnView(){
new Handler().post(new Runnable() {
@Override
public void run() {
sv.scrollTo(0, sv.getTop());
}
});
}
And the other way I am doing it 而我正在这样做的另一种方式
sv.post(new Runnable() {
public void run() {
Log.i(TAG, "TOP TOP");
sv.scrollTo(0, sv.getTop());
}
});
THnaks for the help 求助于此
Use this 用这个
sv.post(new Runnable() {
public void run() {
Log.i(TAG, "TOP TOP");
sv.scrollTo(0, 0);
}
});
Another approach: 另一种方法:
sv.post(new Runnable() {
public void run() {
sv.fullScroll(ScrollView.FOCUS_UP);
}
});
If you want to scroll to bottom, using FOCUS_DOWN. 如果要使用FOCUS_DOWN滚动到底部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.