【问题标题】:How to scroll Item of Horizontal Scrollview inside of display when Click?Click时如何在显示器内滚动Horizo​​ntal Scrollview的项目?
【发布时间】:2019-09-29 09:24:45
【问题描述】:

我正在尝试在手机 like discreatescrollview 的显示屏内滚动 Horizo​​ntalView 的项目。

我正在尝试这个

  private final void focusOnView(final HorizontalScrollView scroll, final View view) {

    new Handler().post(new Runnable() {
        @Override
        public void run() {
            int vLeft = view.getLeft();
            int vRight = view.getRight();
            int sWidth = scroll.getWidth();
            scroll.smoothScrollTo(((vLeft + vRight - sWidth) / 2), 0);
        }
    });
}

但它滚动到中心而不是它的孩子。

我正在尝试添加这样的按钮...

【问题讨论】:

    标签: java android horizontalscrollview


    【解决方案1】:

    我准备在这种情况下使用回收视图,所以我可以添加

    1.snapHelper 捕捉项目 2.添加ItemAnimator,修改很简单 3.将来添加新项目只是在数组中添加新对象 4.滚动动画非常流畅

    【讨论】:

      猜你喜欢
      • 2021-03-30
      • 2021-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-01
      • 2022-07-30
      • 2018-09-12
      • 2015-06-13
      相关资源
      最近更新 更多