Home > Mobile >  TextInputLayout is always focusable when activity start. how can I solve this issue?
TextInputLayout is always focusable when activity start. how can I solve this issue?

Time:11-30

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.

CodePudding user response:

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

CodePudding user response:

In your onCreate try adding this:

edtEmail.isFocusable = false
  • Related