我正在使用fullScroll()
和scrollTo()
函数进行滚动,但是它是有动画效果的,我需要在没有用户观察到的情况下实现滚动。
有没有解决这个问题的方法?
hScrollView.post(new Runnable() {
@Override
public void run() {
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
}
});
我正在使用fullScroll()
和scrollTo()
函数进行滚动,但是它是有动画效果的,我需要在没有用户观察到的情况下实现滚动。
有没有解决这个问题的方法?
hScrollView.post(new Runnable() {
@Override
public void run() {
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
}
});
使用这个
// Disable the animation First
hScrollView.setSmoothScrollingEnabled(false);
// Now scroll the view
hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
// Now enable the animation again if needed
hScrollView.setSmoothScrollingEnabled(true);
在运行Runnable
命令之前,您可以使用hScrollView.setSmoothScrollingEnabled(false);
,这将为您提供所需的输出。
// Set smooth scrolling to false
hScrollView.setSmoothScrollingEnabled(false);
// Then call the fullScroll method
hScrollView.post(new Runnable() {
@Override
public void run() {
hScrollView.fullScroll(View.FOCUS_RIGHT);
}
});