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