I have several EditText
and other components, try that when you press out of EditText
you lose the focus and the keyboard is hidden.
layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/textview_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="textUri"
android:singleLine="true"
tools:text="Dummy text" />
<EditText
android:id="@+id/textview_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="flagNoExtractUi"
android:inputType="textUri"
android:singleLine="true"
tools:text="Dummy text 2" />
<Switch
android:id="@+id/switch_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
The focus is always on the last EditText
, for example if you click on the switch
it operates correctly, but keeping the focus on EditText, so that the keyboard if it is visible is annoying on the screen.