diff --git a/android/app/src/main/java/com/zzang/chongdae/presentation/view/commentdetail/CommentDetailActivity.kt b/android/app/src/main/java/com/zzang/chongdae/presentation/view/commentdetail/CommentDetailActivity.kt index 33d45c56..2f3b1023 100644 --- a/android/app/src/main/java/com/zzang/chongdae/presentation/view/commentdetail/CommentDetailActivity.kt +++ b/android/app/src/main/java/com/zzang/chongdae/presentation/view/commentdetail/CommentDetailActivity.kt @@ -7,6 +7,7 @@ import android.net.Uri import android.os.Bundle import android.view.MotionEvent import android.view.inputmethod.InputMethodManager +import android.widget.EditText import android.widget.Toast import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity @@ -214,8 +215,19 @@ class CommentDetailActivity : AppCompatActivity(), OnUpdateStatusClickListener { } override fun dispatchTouchEvent(motionEvent: MotionEvent): Boolean { - (getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager).apply { - this.hideSoftInputFromWindow(currentFocus?.windowToken, 0) + val view = currentFocus + if (view != null && (view is EditText || view.id == R.id.iv_send_comment)) { + val screenCoords = IntArray(2) + view.getLocationOnScreen(screenCoords) + val x = motionEvent.rawX + view.left - screenCoords[0] + val y = motionEvent.rawY + view.top - screenCoords[1] + + if (motionEvent.action == MotionEvent.ACTION_UP && + (x < view.left || x >= view.right || y < view.top || y > view.bottom) + ) { + val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager + imm.hideSoftInputFromWindow(view.windowToken, 0) + } } return super.dispatchTouchEvent(motionEvent) } diff --git a/android/app/src/main/res/layout/activity_comment_detail.xml b/android/app/src/main/res/layout/activity_comment_detail.xml index 7cc1621f..53b107c6 100644 --- a/android/app/src/main/res/layout/activity_comment_detail.xml +++ b/android/app/src/main/res/layout/activity_comment_detail.xml @@ -259,7 +259,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_20" - android:layout_marginEnd="@dimen/margin_20" + android:layout_marginEnd="@dimen/size_23" android:layout_marginBottom="@dimen/margin_30" android:background="@drawable/bg_gray100_radius_16dp" android:fontFamily="@font/suit_medium"