• lwuit调整滚动条灵敏度值


    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;
            }
        }
  • 相关阅读:
    == 和equals方法
    ObjectInputStream 与ObjectOutputStream
    IOS基础:ObjectiveC 数组处理
    学习笔记:自定义方法的两种实现方式
    DatePicker 获取时间的时区问题
    IOS基础:tableview中cell
    IOS基础:窗口切换的几种方法
    IOS基础:ObjectiveC 字符串处理
    使用 Notifications
    学习笔记:Tab Bar 控件使用详解
  • 原文地址:https://www.cnblogs.com/datong/p/1542594.html
Copyright © 2020-2023  润新知