zoukankan      html  css  js  c++  java
  • 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;
            }
        }
  • 相关阅读:
    下拉选择框:数字从n到m
    event.target返回事件的目标节点(触发该事件的节点)
    nextSibling使用注意(html的注释)
    mysql导出 csv文件
    ie打印去掉页眉页脚
    jsp标签循环标签体
    String.format字符串格式化方法
    [**奇文共赏**补充问题] 据说看五遍能懂的人智商 > 200
    [转] ARP的处理办法!
    [转] 一张废手机卡的作用大全 (没试过)
  • 原文地址:https://www.cnblogs.com/datong/p/1542594.html
Copyright © 2011-2022 走看看