lwuit---调整滚动条灵敏度值

来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 00:28 点击:
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;
        }
    }

本文出自 “技术人生” 博客,请务必保留此出处http://zhaohaiyang.blog.51cto.com/2056753/435607

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Java编程语言的八大优点
      • JVM对象生命周期详细介绍
      • Java平台上的CRM系统
      • Java 算数测试小程序
      • Command(命令模式)
      • Java 一个简单的画图程序
      • Java环境 使用Resin在NT环境下配置JSP环境
      • Java 日历的小程序
      • Java 统计代码的小工具
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1