override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
val focusView = currentFocus
if (focusView != null) {
val rect = Rect()
focusView.getGlobalVisibleRect(rect)
val x = ev!!.x.toInt()
val y = ev!!.y.toInt()
if (!rect.contains(x, y)) {
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(focusView.windowToken, 0)
focusView.clearFocus()
}
}
return super.dispatchTouchEvent(ev)
}
'Android - Snippet' 카테고리의 다른 글
[Android] aab를 apk로 변환 (1) | 2022.02.10 |
---|---|
[Android] StatusBar 없애기/색상변경/글자색상변경 (0) | 2021.11.27 |
[Android] ExifInterface Under Nougat(7.0) (1) | 2021.11.25 |
[Android] PxToDp, DpToPx (0) | 2021.11.12 |
[Android] View 이미지 캡쳐(Get Bitmap From View) (0) | 2021.10.14 |