0

When activity is started TextInputlayout with edittext always auto focasable. i try

android:focusableInTouchMode="true"

but it doesn't work. Hear is my code.

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textInputMobile"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:errorEnabled="true"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/tvMessage">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/edtEmail"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:drawableStart="@drawable/ic_mobile"
        android:drawablePadding="@dimen/_3sdp"
        **android:focusableInTouchMode="true"**
        android:fontFamily="@font/montserrat_regular"
        android:hint="@string/str_mobile_number"
        android:inputType="number"
        android:maxLength="10"
        android:paddingVertical="@dimen/_9sdp"
        android:textColor="@color/colorBlack"
        android:textSize="@dimen/_10ssp" />
</com.google.android.material.textfield.TextInputLayout>

I want to enable focus only when i touch the edit text.

  • 2
    Does [this](https://stackoverflow.com/questions/6122704/hide-soft-keyboard-on-application-load) solve your problem? – Vucko Nov 30 '22 at 11:23

2 Answers2

0

if you are using this attribute :

 android:focusableInTouchMode="true"

then you should easily combine this one with it in the same EditText's root :

android:focusable="true"

I don't see your goal doing that but it should be working fine

providerZ
  • 315
  • 11
  • i already try android:focusable="true" but it does't work. i want to just disable auto focus when activity started. – Akshay Hadiya Nov 30 '22 at 13:35
  • I tried to use the normal EditText instead of: com.google.android.material.textfield.TextInputEditText and without the 2 attributes that i provided in the answer and it works fine with me maybe you have something added in programing codes to make it behave like that @AkshayHadiya – providerZ Nov 30 '22 at 16:07
0

In your onCreate try adding this:

edtEmail.isFocusable = false
Mert
  • 904
  • 4
  • 9
  • 21