ViewConfiguration.getScaledTouchSlop() 的基本用法

getScaledTouchSlop() 的返回值為 int 類型,表示一次滑動的距離。一般的用法為:獲得?手指的滑動距離,值為 A ,當(dāng)? A 的大小大于該 API 返回的值時開始滑動控件,反之,控件不移動。

ViewConfiguration 相關(guān)屬性的獲取方式

ViewConfiguration.get(context).getXXX();

ViewConfiguration 滑動參數(shù)?類

/**
*Contains methods to standard constants used in the UI for *timeouts, sizes, and distances.
* UI 中時間、大小、距離的常量
*/
public class ViewConfiguration {     
   // 設(shè)定水平滾動條的寬度和垂直滾動條的高度,單位是像素px     
   private static final int SCROLL_BAR_SIZE = 10;     
        
   //定義滾動條逐漸消失的時間,單位是毫秒     
   private static final int SCROLL_BAR_FADE_DURATION = 250;     
        
   // 默認(rèn)的滾動條多少秒之后消失,單位是毫秒     
   private static final int SCROLL_BAR_DEFAULT_DELAY = 300;     
        
   // 定義邊緣地方褪色的長度     
   private static final int FADING_EDGE_LENGTH = 12;     
        
   //定義子控件按下狀態(tài)的持續(xù)事件     
   private static final int PRESSED_STATE_DURATION = 125;     
            
   //定義一個按下狀態(tài)轉(zhuǎn)變成長按狀態(tài)的轉(zhuǎn)變時間     
   private static final int LONG_PRESS_TIMEOUT = 500;     
            
   //定義用戶在按住適當(dāng)按鈕,彈出全局的對話框的持續(xù)時間     
   private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;     
            
   //定義一個touch事件中是點(diǎn)擊事件還是一個滑動事件所需的時間,如果用戶在這個時間之內(nèi)滑動,那么就認(rèn)為是一個點(diǎn)擊事件     
   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事件時候是一個點(diǎn)擊事件。如果用戶在這個時間內(nèi)沒有完成這個點(diǎn)擊,那么就認(rèn)為是一個點(diǎn)擊事件     
   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;     
        
   //視圖繪圖緩存的最大尺寸,以字節(jié)表示。在ARGB888格式下,這個尺寸應(yīng)至少等于屏幕的大小     
   @Deprecated     
   private static final int MAXIMUM_DRAWING_CACHE_SIZE = 320 * 480 * 4; // HVGA screen, ARGB8888     
        
   //flings和scrolls摩擦力度大小的系數(shù)     
   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;    

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • ¥開啟¥ 【iAPP實(shí)現(xiàn)進(jìn)入界面執(zhí)行逐一顯】 〖2017-08-25 15:22:14〗 《//首先開一個線程,因...
    小菜c閱讀 7,335評論 0 17
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,058評論 25 709
  • 《ilua》速成開發(fā)手冊3.0 官方用戶交流:iApp開發(fā)交流(1) 239547050iApp開發(fā)交流(2) 1...
    葉染柒丶閱讀 11,507評論 0 11
  • 這是一個由新媒體引領(lǐng)的時代,內(nèi)容為王引發(fā)全面井噴,每天都有大量的文字作品進(jìn)入到讀者的視野中,每天都有佼佼者脫穎而出...
    南嶺雪閱讀 508評論 16 11
  • 第一部分 為什么一定要等到受到挫折才成長? 萬物皆有裂痕,那是光進(jìn)來的地方。似乎有這么一個說法,多經(jīng)歷苦難,才能...
    夢夕夢閱讀 272評論 0 4

友情鏈接更多精彩內(nèi)容