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. }
相關文章
相關標籤/搜索