原文链接:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2013/0225/907.html

getScaledTouchSlop是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件。如果小于这个距离就不触发移动控件,如viewpager就是用这个距离来判断用户是否翻页

ViewConfiguration滑动参数设置类:

/**    * 包含了方法和标准的常量用来设置UI的超时、大小和距离    */ public class ViewConfiguration {     // 设定水平滚动条的宽度和垂直滚动条的高度,单位是像素px     private static final int SCROLL_BAR_SIZE = 10;     //定义滚动条逐渐消失的时间,单位是毫秒     private static final int SCROLL_BAR_FADE_DURATION = 250;     // 默认的滚动条多少秒之后消失,单位是毫秒     private static final int SCROLL_BAR_DEFAULT_DELAY = 300;     // 定义边缘地方褪色的长度     private static final int FADING_EDGE_LENGTH = 12;     //定义子控件按下状态的持续事件     private static final int PRESSED_STATE_DURATION = 125;     //定义一个按下状态转变成长按状态的转变时间     private static final int LONG_PRESS_TIMEOUT = 500;     //定义用户在按住适当按钮,弹出全局的对话框的持续时间     private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;     //定义一个touch事件中是点击事件还是一个滑动事件所需的时间,如果用户在这个时间之内滑动,那么就认为是一个点击事件     private static final int TAP_TIMEOUT = 115;     /**    * Defines the duration in milliseconds we will wait to see if a touch event     * is a jump tap. If the user does not complete the jump tap within this interval, it is    * considered to be a tap.     */ //定义一个touch事件时候是一个点击事件。如果用户在这个时间内没有完成这个点击,那么就认为是一个点击事件     private static final int JUMP_TAP_TIMEOUT = 500;     //定义双击事件的间隔时间     private static final int DOUBLE_TAP_TIMEOUT = 300;     //定义一个缩放控制反馈到用户界面的时间     private static final int ZOOM_CONTROLS_TIMEOUT = 3000;     /**    * Inset in pixels to look for touchable content when the user touches the edge of the screen    */ private static final int EDGE_SLOP = 12;     /**    * Distance a touch can wander before we think the user is scrolling in pixels    */ private static final int TOUCH_SLOP = 16;     /**    * Distance a touch can wander before we think the user is attempting a paged scroll    * (in dips)    */ private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;     /**    * Distance between the first touch and second touch to still be considered a double tap    */ private static final int DOUBLE_TAP_SLOP = 100;     /**    * Distance a touch needs to be outside of a window's bounds for it to    * count as outside for purposes of dismissing the window.    */ private static final int WINDOW_TOUCH_SLOP = 16;     //用来初始化fling的最小速度,单位是每秒多少像素     private static final int MINIMUM_FLING_VELOCITY = 50;     //用来初始化fling的最大速度,单位是每秒多少像素     private static final int MAXIMUM_FLING_VELOCITY = 4000;     //视图绘图缓存的最大尺寸,以字节表示。在ARGB888格式下,这个尺寸应至少等于屏幕的大小     @Deprecated     private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // HVGA screen, ARGB8888     //flings和scrolls摩擦力度大小的系数     private static float SCROLL_FRICTION = 0.015f;     /**    * Max distance to over scroll for edge effects    */ private static final int OVERSCROLL_DISTANCE = 0;     /**    * Max distance to over fling for edge effects    */ private static final int OVERFLING_DISTANCE = 4;     }

原文链接:http://blog.csdn.net/freedom13905149949/article/details/51661019

这篇博客的目的在于借助于ScrollView这个控件为大家讲解在我们平常的安卓开发过程经常使用的关于View的滑动知识

1、ScrollView的构造方法

public ScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);initScrollView();final TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ScrollView, defStyleAttr, defStyleRes);setFillViewport(a.getBoolean(R.styleable.ScrollView_fillViewport, false));a.recycle();}

大家发现ScrollView这个构造方法里面一共有四个参数,其实所有的View都是按照View的规则绘制出来的,这四个参数照样适用于其他View的自定义

2、initScrollView()这个方法的源代码:

private void initScrollView() {mScroller = new OverScroller(getContext());setFocusable(true);setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);setWillNotDraw(false);final ViewConfiguration configuration = ViewConfiguration.get(mContext);mTouchSlop = configuration.getScaledTouchSlop();mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();mOverscrollDistance = configuration.getScaledOverscrollDistance();mOverflingDistance = configuration.getScaledOverflingDistance();}

详细解释这个类里面用到的API

//这个方法的参数表示当前是否获得焦点
setFocusable(boolean flag);setDescendantFocusability(int flag);//如果要重写这个View的onDraw()方法,设置这个标志位false会走重写过的方法
setWillNotDraw(boolean flag);

ViewConfiguration

//能够识别的最小滑动举例
ViewConfiguration.getScaledTouchSlop();//最小加速度
ViewConfigurationgetScaledMinimumFlingVelocity();//最大加速度
ViewConfiguration.getScaledMaximumFlingVelocity();//滚动距离
ViewConfiguration.getScaledOverscrollDistance();//Filing距离
ViewConfiguration.getScaledOverflingDistance();

ViewConfiguration.getScaledTouchSlop () 用法相关推荐

  1. 了解ViewConfiguration

    简介: ViewConfiguration这个类主要定义了UI中所使用到的标准常量, 像超时.尺寸.距离,如果我们需要得到这些常量的数据,我们就可以通过这个类来获取,具体方法如下: 1.获取ViewC ...

  2. 学习使用安卓scroller

    Android Scroller 解读编写Demo Scroller是一个专门用于处理滚动效果的工具类,大多数情况下,我们直接使用Scroller的场景并不多,但是很多大家所熟知的控件在内部都是使用S ...

  3. android 方法技巧

    Github网站:https://github.com/tangqi92/Android-Tips: 1.Throwable接口中的getStackTrace()方法(或者Thread类的getSta ...

  4. 安卓代码中常用的代码以及问题收集

    EnglishVersion ->_->:https://raw.githubusercontent.com/jiang111/awesome-android-tips/master/RE ...

  5. android 刷新某条数据_Android 支持刷新、加载更多、带反弹效果的RecyclerView

    点击上方"Android技术杂货铺",选择"标星" 干货文章,第一时间送达! 开篇 当前市面上很多支持刷新.加载更多RecyclerView开源库,为何我这里还 ...

  6. 安卓开发仿微信图片拖拽_使用Android 模仿微信朋友圈图片拖拽返回

    1概述 目前的app的动画效果是越来越炫了,很多主流app的图片预览返回都有类似功能,比较常见的是ios自带相册,微信朋友圈等等.自己项目中也有类似功能,最近整理了一下这个功能的代码,做个笔记记录,有 ...

  7. Android 小技巧

    为什么80%的码农都做不了架构师?>>>    原文出处: Dan Lew   译文出处:Android Performance 前言 本文是一篇译文,这篇是这个系列的第一篇.讲述的 ...

  8. 安卓开发仿微信图片拖拽_Android 仿微信朋友圈图片拖拽返回

    目前的app的动画效果是越来越炫了,很多主流app的图片预览返回都有类似功能,比较常见的是ios自带相册,微信朋友圈等等.自己项目中也有类似功能,最近整理了一下这个功能的代码,做个笔记记录,有兴趣的朋 ...

  9. 实现ViewPager一次滑动多页(保持居中)

    项目中开发日历功能,需求是可以连续滑动多页,有列表的流畅.又要保持当前页居中显示. 参考文献:  http://www.open-open.com/lib/view/open1435026935638 ...

最新文章

  1. 清华大学人工智能研究院成立自然语言处理与社会人文计算研究中心
  2. (Application下)组件(所在的)进程创建时,创建Application
  3. Product description search in opportunity line item
  4. linux自动获取ip网卡配置文件,linux 命令行下配置网卡自动获取 IP
  5. 巨蟒python全栈开发flask5
  6. 解决jboss.resteasy.spi.UnhandledException: Response is committed, can‘t handle exception
  7. fullcalendar php,日历插件fullcalendar+php的使用教程 — 读取json数据
  8. AndroidStudio_开发工具调试入门---Android原生开发工作笔记70
  9. matlab要求 基础,Matlab基础考试要求.doc
  10. Objective-C 与JAVA的SHA1/HmacSHA1加密算法实现
  11. 关于滚动条ScrollView
  12. ASP.NET加密解密
  13. 千月最新影视APICLOUD完整安卓程序源码+UI非常不错
  14. Windows 好用的护眼软件
  15. 什么是主数据?什么是主数据管理系统?
  16. android 手机 报证书错误,安卓 ssl证书 安卓ssl证书出现错误的可能原因? - SSL网...
  17. 珠宝行业电子秤串口程序开发
  18. Sony WH-1000XM3降级到2.00
  19. 系统时间不够精确?试试RTC(实时时钟)
  20. 【地图匹配(ST-matching)】GPS 轨迹数据预处理——T-Driver数据集【持续更新中】

热门文章

  1. apache基于ip如何配置虚拟主机
  2. windows下编译zlib
  3. 【数据库】数据库单表对比
  4. 发现一个电子书下载的【简书】
  5. 树结构(三)----线索二叉树
  6. 剑指Offer之栈的压入、弹出序列
  7. Html之head部分详解
  8. python学习笔记系列----(五)输入和输出
  9. Windows下sc create命令行添加/创建/修改服务
  10. bzoj1116 [POI2008]CLO