Как изменить FloatingPlaceholderColor, но не цвет подсказки в textinputlayout в android - PullRequest
0 голосов
/ 21 марта 2020

Я создал TextInputLayout (OutlinedBox) с подсказкой. Ожидается, что будет отображаться в 3 цветах.

  1. Когда заполнитель сфокусирован, «плавающая метка» должна отображаться в цвете 1 (ЖЕЛТЫЙ)
  2. Когда заполнитель не сфокусирован, «подсказка» должна отображаться в цвете 2 (СЕРЫЙ)
  3. Когда заполнитель не сфокусирован, «плавающая метка» должна отображаться в цвете (СИНИЙ)

Однако не сфокусированная «подсказка» и не сфокусированная «плавающая метка» всегда принимают один и тот же цвет как назначить в качестве заполнителя (в данном случае цвет 2- серый).

enter image description here

Здесь я использовал зависимость com.google.android.material:material:1.2.0-alpha05

<com.google.android.material.textfield.TextInputLayout
        android:id="@+id/tv_mb_text_layout3"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/tv_mb_text_layout2"
        app:layout_constraintLeft_toLeftOf="parent"
        style="@style/MBFormTextInputStyle"
        android:hint="label_text"
        app:errorEnabled="true">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:text="Priyanka"
            android:layout_height="wrap_content"/>

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

    <!-- Style for Hint -->
    <style name="hint_appearance" parent="TextAppearance.AppCompat">
        <item name="android:textSize">8sp</item>
        <item name="android:textColor">@android:color/holo_orange_dark</item>
    </style>

    <style name="MBFormTextInputStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
        <item name="errorTextAppearance">@style/error_a`enter code here`ppearance</item>
        <item name="errorTextColor">@android:color/holo_purple</item>
        <item name="boxStrokeErrorColor">@android:color/holo_purple</item>
        <item name="hintTextAppea`enter code here`rance">@style/hint_appearance</item>
        <item name="hintTextColor">@android:color/holo_blue_dark</item>
        <item name="android:textColorHint">@android:color/holo_purple</item>
    </style>

enter image description here

...