Shi*_*own 33 android scrollview smooth-scrolling
我有一个滚动视图.我执行了smooth-scroll.using smoothScrollBy().一切正常,但我想改变平滑滚动的持续时间.平滑滚动发生得非常快,用户不了解发生了什么.请帮我降低平滑滚动速度?
365*_*uns 162
简单的答案就是替换
scrollView.smoothScrollTo(0, scrollTo);
Run Code Online (Sandbox Code Playgroud)
同
ObjectAnimator.ofInt(scrollView, "scrollY", scrollTo).setDuration(duration).start();
Run Code Online (Sandbox Code Playgroud)
这里duration是你希望它在几毫秒的时间.
Muz*_*ant 13
请尝试以下代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
ValueAnimator realSmoothScrollAnimation =
ValueAnimator.ofInt(parentScrollView.getScrollY(), targetScrollY);
realSmoothScrollAnimation.setDuration(500);
realSmoothScrollAnimation.addUpdateListener(new AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
int scrollTo = (Integer) animation.getAnimatedValue();
parentScrollView.scrollTo(0, scrollTo);
}
});
realSmoothScrollAnimation.start();
}
else
{
parentScrollView.smoothScrollTo(0, targetScrollY);
}
Run Code Online (Sandbox Code Playgroud)
Raj*_*til -2
whichScreen = Math.max(0, Math.min(whichScreen, getBase().getDocumentModel().getPageCount()-1));
mNextScreen = whichScreen;
final int newX = whichScreen * getWidth();
final int delta = newX - getScrollX();
//scroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta) * 2);
scroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta));
invalidate();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44415 次 |
| 最近记录: |