Like the hundreds questions out there I want to change na color of the hint. Originally i wanted to ask in the comments of another such question(unanswered) but I don't have enough reputation so I ask here.
I want when the hint is in the TextInputEditText to be one color, and when it is floating to be another. In the other posts the answers are always how to change the hint when the view is focused. That is not what i want, I can do that. I want to change the hint color if the Edit Text is not empty. I'm using material design textInputLayout and textInputEditText. Tried different styles and selectors and still can't do it. Tried to extend TextInputLayout but i don't know how to bind it to EditText so that i can use OnTextListener for the child view.
My code so far can change the color of the hint only when the view is focused.
Styles:
<style name="TextInputLayoutAppearance" parent="Widget.Design.TextInputLayout">
<item name="colorControlNormal">@color/green_03</item>
<item name="colorControlActivated">@color/green_03</item>
<item name="hintTextColor">@color/dark_blue_60</item>
</style>
<style name="MyHintStyle" parent="@android:style/TextAppearance">
<!-- Hint color when floating and focused-->
<item name="android:textColor">@color/dark_blue_60</item>
<!-- doesn't change anything -->
<item name="android:textColorHint">@color/dark_blue</item>
<item name="colorAccent">@color/green_03</item>
<item name="colorControlNormal">@color/green_03</item>
<item name="colorControlActivated">@color/green_03</item>
</style>
XML:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:textColorHint="@color/dark_blue"
android:theme="@style/TextInputLayoutAppearance"
app:errorEnabled="true"
app:hintTextAppearance="@style/MyHintStyle">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/green_03"
android:hint="@string/phoneNumber"
android:textColor="@color/dark_blue"
android:inputType="number"
android:maxLength="3"
android:text="12" />
</com.google.android.material.textfield.TextInputLayout>
Is there a way to extend and change it programmatically for all views or set a global listener or a right way to use styles and selectors.