TextInputLayout меняет цвет границы, когда он содержит текст - PullRequest
0 голосов
/ 20 февраля 2020

Я хочу изменить цвет поля TextInputLayout, если он содержит какой-либо текст, или поддерживает состояние фокусировки, когда он содержит текст.

Мой код:

 <com.google.android.material.textfield.TextInputLayout
   android:id="@+id/et_email_layout"
   style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginStart="16dp"
   android:layout_marginTop="40dp"
   android:layout_marginEnd="16dp"
   android:hint="@string/email"
   android:textColorHint="@color/grey_40"
   app:layout_constraintEnd_toEndOf="parent"
   app:layout_constraintStart_toStartOf="parent"
   app:layout_constraintTop_toBottomOf="@+id/et_url_layout">

   <com.google.android.material.textfield.TextInputEditText
      android:id="@+id/et_email"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:backgroundTint="@android:color/transparent"
      android:drawableEnd="@drawable/ic_email"
      android:inputType="textEmailAddress"
      android:maxLength="20"
      android:maxLines="1"
      android:paddingStart="10dp"
      android:paddingEnd="10dp"
      android:singleLine="true"
      android:textColor="@color/color_text" />

</com.google.android.material.textfield.TextInputLayout>

Выход:

enter image description here

При фокусировке:

enter image description here

Расфокусировка:

enter image description here

Я хочу достичь того же состояния фокуса, когда оно содержит некоторый текст.

Любая помощь будет высоко оценена.

Спасибо!

...