0

In my xml layout:

  <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/nameTextInputEditText"
            style="@style/textViewOneLine"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/default_margin"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:hint="@string/name"
            android:textColor="@android:color/white"
            android:textColorHint="@android:color/white"
            android:textSize="17sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/toolBarContainer" />

But when show activity the soft keyboard is not show. I must click to TextInputEditText to show keyboard.

this not help:

   android:focusable="true"
   android:focusableInTouchMode="true"
a_subscriber
  • 8,977
  • 15
  • 60
  • 141
  • Possible duplicate of [How to hide Soft Keyboard when activity starts](https://stackoverflow.com/questions/18977187/how-to-hide-soft-keyboard-when-activity-starts) – cutiko Nov 07 '19 at 15:28
  • In the duplicated question there are a lot of solutions, I would recommend https://stackoverflow.com/a/36710556/4017501 it has the lesser impact – cutiko Nov 07 '19 at 15:29

2 Answers2

0

Despite the fact, that this should work.

Make sure your parent layout is not is focusable mode. Also make sure the parent layout is a Relative or Linear.

If all of that fails try the following: Add this to your main activity in onCreate after setContentView. Let us what happens.

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
Miriana Itani
  • 793
  • 7
  • 21
0

Try adding this to your xml layout.

android:focusedByDefault="true"
Jo Momma
  • 390
  • 1
  • 19