Component类中:
        //设置滚动条灵敏度
        public void pointerReleased(int x, int y) {
        
if (dragActivated) {
            
long currentTime = System.currentTimeMillis();

            
// replace x and y if this is an x scrolling container
            if (!isScrollableY()) {
                y 
= x;
            }

            
if (currentTime != lastTime[(pLastDragged + lastTime.length + 1% lastTime.length]) {
                lastTime[pLastDragged] 
= System.currentTimeMillis();
                lastDragged[pLastDragged] 
= y;
                pLastDragged 
= (++pLastDragged) % lastTime.length;
            }
            
float velocity = (float) (lastDragged[pLastDragged] - lastDragged[(pLastDragged + lastDragged.length + 1% lastDragged.length]) / (lastTime[pLastDragged] - lastTime[(pLastDragged + lastTime.length + 1% lastTime.length]);
            velocity 
= velocity * -1;

       
//默认为0.0004f ,越小灵敏度越高
            if (isScrollableY()) {
                draggedMotion 
= Motion.createFrictionMotion(scrollY, velocity, 0.0008f);
            } 
else {
                draggedMotion 
= Motion.createFrictionMotion(scrollX, velocity, 0.0008f);
            }


            draggedMotion.start();
            dragActivated 
= false;
        }
    }

相关文章:

  • 2021-04-06
  • 2021-12-21
  • 2021-08-13
  • 2021-04-15
  • 2021-06-05
  • 2021-04-16
  • 2021-09-02
  • 2021-05-31
猜你喜欢
  • 2021-09-13
  • 2021-06-24
  • 2021-09-27
  • 2021-07-26
  • 2021-10-28
  • 2021-12-12
  • 2021-10-23
相关资源
相似解决方案