1

I've DialogFragment and three TextInputLayouts. When I click on the first TextInputLayout then the keyboard opens. And it does not disappear when you click on others TextInputLayout.

getDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) 

or

android:windowSoftInputMode="stateHidden" 

don't work.

How to solve a problem?

My .xml code

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<android.support.design.widget.TextInputLayout 
android:id="@+id/tilDialogTaskTitle" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_marginLeft="16dp" 
android:layout_marginTop="16dp" 
android:layout_marginRight="16dp"> 
<EditText 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:textSize="16sp"/> 

</android.support.design.widget.TextInputLayout> 

<android.support.design.widget.TextInputLayout 
android:id="@+id/tilDialogTaskDate" 
android:layout_width="130dp" 
android:layout_below="@+id/tilDialogTaskTitle" 
android:layout_height="wrap_content" 
android:layout_marginLeft="16dp" 
android:layout_marginTop="16dp" 
android:layout_marginRight="16dp"> 
<EditText 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:textSize="16sp" 
android:inputType="none" 
android:focusableInTouchMode="false" 
android:cursorVisible="false"/> 

</android.support.design.widget.TextInputLayout> 

<android.support.design.widget.TextInputLayout 
android:id="@+id/tilDialogTaskTime" 
android:layout_width="130dp" 
android:layout_alignRight="@+id/tilDialogTaskTitle" 
android:layout_below="@+id/tilDialogTaskTitle" 
android:layout_height="wrap_content" 
android:layout_marginTop="16dp"> 
<EditText 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:textSize="16sp" 
android:inputType="none" 
android:focusableInTouchMode="false" 
android:cursorVisible="false"/> 

</android.support.design.widget.TextInputLayout> 

<Spinner 
android:id="@+id/spDialogTaskPriority" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_below="@+id/tilDialogTaskDate" 
android:layout_marginRight="16dp" 
android:layout_marginLeft="16dp" 
android:layout_marginTop="10dp" 
/> 

</RelativeLayout> 

</ScrollView>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
julivalex
  • 11
  • 2
  • https://stackoverflow.com/questions/41725817/hide-to-show-and-hide-keyboard-in-dialogfragment – Rohan Stark Jul 02 '17 at 22:06
  • I used these methods. They do not work. I do not need to remove the focus in onResume(), only by clicking on TextInputLayout – julivalex Jul 03 '17 at 07:50

0 Answers0