MotionEventCompat的輔助方法從MotionEvent類中讀取信息,
使用GestureDetectorCompat進(jìn)行兼容性的手勢檢測MotionEvent類包含了觸點id(多點觸控支持),位置,壓力等眾多信息,
用于進(jìn)行手勢檢測GestureDetector/GestureDetectorCompat類進(jìn)行手勢檢測,
傳入GestureDetector.OnGestureListener實現(xiàn)類,在View/Activity的
onTouchEvent中把MotionEvent對象傳入detector,系統(tǒng)將會在特定手勢
觸發(fā)時調(diào)用回調(diào),例如:fling, long press等VelocityTracker和VelocityTrackerCompat類,
代碼示例Scroller或者OverScroller了OverScroller,因為它的兼容性更好,此外,對于內(nèi)容的滾動需求,
應(yīng)該使用ScrollView或者HorizontalScrollViewGestureDetector.OnGestureListener::onScroll()方法即可GestureDetector.OnGestureListener:: onFling()且結(jié)合scrollerACTION_POINTER_DOWN, ACTION_POINTER_UPView.OnDragListener可供使用,包括drag drop 陰影等ScaleGestureDetector來進(jìn)行view的縮放支持onInterceptTouchEvent()函數(shù)攔截對子View的點擊事件ViewConfiguration類獲取系統(tǒng)定義的一系列常量:間距,速度,時間等TouchDelegate類,擴(kuò)展子View的點擊熱區(qū),使其點擊熱區(qū)大于子View的邊界inputType屬性設(shè)置輸入類型,一方面控制輸入法的輸入模式,
另一方面限制輸入內(nèi)容android:inputType="textCapSentences|textAutoCorrect"android:imeOptions="actionSend", actionSearcheditText.setOnEditorActionListener鍵盤可見性變化
android:windowSoftInputMode="stateVisible"代碼主動顯示鍵盤
public void showSoftKeyboard(View view) {
if (view.requestFocus()) {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
}
windowSoftInputMode來控制鍵盤彈起時Layout的變化:
adjustResize, adjustPan, adjustUnspecified, adjustNothingadjustNothing時,KeyboardVisibilityEvent庫可以檢測鍵盤彈出和收起事件,也提供了
手動彈出和收起的方法android:nextFocusForward屬性,指定當(dāng)前View在獲得焦點狀態(tài)下,按下tab鍵,
焦點移動的下一個View的idandroid:nextFocusUp, android:nextFocusDown, android:nextFocusLeft,
android:nextFocusRightKeyEvent.Callback接口可以監(jiān)聽鍵盤事件