ViewConfiguration.getScaledTouchSlop () 用法

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

 

ViewConfiguration滑动参数设置类:ide

 
  1. /**
  2. * 包含了方法和标准的常量用来设置UI的超时、大小和距离
  3. */
  4. public class ViewConfiguration {
  5. // 设定水平滚动条的宽度和垂直滚动条的高度,单位是像素px
  6. private static final int SCROLL_BAR_SIZE = 10;
  7.  
  8. //定义滚动条逐渐消失的时间,单位是毫秒
  9. private static final int SCROLL_BAR_FADE_DURATION = 250;
  10.  
  11. // 默认的滚动条多少秒以后消失,单位是毫秒
  12. private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
  13.  
  14. // 定义边缘地方褪色的长度
  15. private static final int FADING_EDGE_LENGTH = 12;
  16.  
  17. //定义子控件按下状态的持续事件
  18. private static final int PRESSED_STATE_DURATION = 125;
  19.  
  20. //定义一个按下状态转变成长按状态的转变时间
  21. private static final int LONG_PRESS_TIMEOUT = 500;
  22.  
  23. //定义用户在按住适当按钮,弹出全局的对话框的持续时间
  24. private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
  25.  
  26. //定义一个touch事件中是点击事件仍是一个滑动事件所需的时间,若是用户在这个时间以内滑动,那么就认为是一个点击事件
  27. private static final int TAP_TIMEOUT = 115;
  28.  
  29. /**
  30. * Defines the duration in milliseconds we will wait to see if a touch event
  31. * is a jump tap. If the user does not complete the jump tap within this interval, it is
  32. * considered to be a tap.
  33. */
  34. //定义一个touch事件时候是一个点击事件。若是用户在这个时间内没有完成这个点击,那么就认为是一个点击事件
  35. private static final int JUMP_TAP_TIMEOUT = 500;
  36.  
  37. //定义双击事件的间隔时间
  38. private static final int DOUBLE_TAP_TIMEOUT = 300;
  39.  
  40. //定义一个缩放控制反馈到用户界面的时间
  41. private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
  42.  
  43. /**
  44. * Inset in pixels to look for touchable content when the user touches the edge of the screen
  45. */
  46. private static final int EDGE_SLOP = 12;
  47.  
  48. /**
  49. * Distance a touch can wander before we think the user is scrolling in pixels
  50. */
  51. private static final int TOUCH_SLOP = 16;
  52.  
  53. /**
  54. * Distance a touch can wander before we think the user is attempting a paged scroll
  55. * (in dips)
  56. */
  57. private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
  58.  
  59. /**
  60. * Distance between the first touch and second touch to still be considered a double tap
  61. */
  62. private static final int DOUBLE_TAP_SLOP = 100;
  63.  
  64. /**
  65. * Distance a touch needs to be outside of a window's bounds for it to
  66. * count as outside for purposes of dismissing the window.
  67. */
  68. private static final int WINDOW_TOUCH_SLOP = 16;
  69.  
  70. //用来初始化fling的最小速度,单位是每秒多少像素
  71. private static final int MINIMUM_FLING_VELOCITY = 50;
  72.  
  73. //用来初始化fling的最大速度,单位是每秒多少像素
  74. private static final int MAXIMUM_FLING_VELOCITY = 4000;
  75.  
  76. //视图绘图缓存的最大尺寸,以字节表示。在ARGB888格式下,这个尺寸应至少等于屏幕的大小
  77. @Deprecated
  78. private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // HVGA screen, ARGB8888
  79.  
  80. //flings和scrolls摩擦力度大小的系数
  81. private static float SCROLL_FRICTION = 0.015f;
  82.  
  83. /**
  84. * Max distance to over scroll for edge effects
  85. */
  86. private static final int OVERSCROLL_DISTANCE = 0;
  87.  
  88. /**
  89. * Max distance to over fling for edge effects
  90. */
  91. private static final int OVERFLING_DISTANCE = 4;
  92.  
  93. }
相关文章
相关标签/搜索