【问题标题】:how to scroll horizontal scroll view without animation如何在没有动画的情况下滚动水平滚动视图
【发布时间】:2012-06-26 14:56:03
【问题描述】:

问题是我正在使用 fullScroll()scrollTo() 函数进行滚动,但它是动画的,我需要它在没有用户观察的情况下发生。

有没有办法解决这个问题?

hScrollView.post(new Runnable() {
    @Override
    public void run() {
        hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
    }
});

【问题讨论】:

  • 试试 hScrollView.fullScroll(ScrollView.FOCUS_LEFT);
  • 谢谢,但我之前试过了,我也遇到了同样的问题!
  • 但是动画有什么问题呢?我认为如果他们看到滚动而不是跳转到另一个位置,用户体验会更好。

标签: android animation scrollview


【解决方案1】:

使用这个

// 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);

【讨论】:

    【解决方案2】:

    您可以在运行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);
                }
            });
    

    【讨论】:

      猜你喜欢
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多