0
사용자가 화면의 EditText가 아닌 다른 것을 터치하면 소프트 키보드가 사라지게하고 싶습니다. 전에이 질문에 대한 게시물을 살펴본 후 onFocusChangeListener를 사용하여 구현했지만 다른 프로젝트에서 그 트릭을 수행했지만 지금은 작동하지 않는 것 같고 잘못된 점을 파악할 수 없습니다. 어떤 도움을 주셔서 감사합니다.안드로이드에서 onFocusChangeListener와 함께 작동하지 않는 소프트 키보드를 숨기기
내 activity.java (inputGuardian1는 글고의 예)
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<!--android:layout_marginTop="?attr/actionBarSize"-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_guardian1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputGuardian1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="Guardian 1" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_Guardian2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputGuardian2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="Guardian 2" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_Guardian3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputGuardian3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="Guardian 3" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_Guardian4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputGuardian4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:imeOptions="actionDone"
android:hint="Guardian 4" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="40sp"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_ChildName"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/inputChildName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Child's Name"
android:layout_marginTop="30sp"
android:imeOptions="actionDone"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button android:id="@+id/buttonNext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
android:background="@color/colorPrimary"
android:layout_marginTop="40dp"
android:textColor="@android:color/white" />
</LinearLayout>
</ScrollView>
참조 http://stackoverflow.com/questions/4165414/how-to-hide-soft-keyboard-on-android-after-clicking-outside-edittext – Nikhil
감사. 나는 그 문제를 해결했다. 모든 컨테이너에 두 속성을 추가해야했습니다 : android : clickable = "true"'and'android : focusableInTouchMode = "true"' – skbrhmn