Change Edittext Hint Color When Using Textinputlayout

Change EditText hint color when using TextInputLayout

Looks like the parent view had a style for a 3rd party library that was causing the EditText to be white.

android:theme="@style/com_mixpanel_android_SurveyActivityTheme"

Once I removed this everything worked fine.

How to change the TextInputEditText floating hint color when not focused

Add this code into your style.xml file ->

<style name="TextLabelDummy" parent="Widget.MaterialComponents.TextInputLayout.FilledBox.Dense">
<item name="colorAccent">@color/black</item> // Text Color
<item name="android:textColorHint">@color/blue</item> // Hint Color
<item name="colorControlActivated">@color/white</item> //Floating label color
</style>

You can change the parent attribute whatever you want. I've randomly used the "Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"

Then call this as theme into you layout file

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayoutNumberDummy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="32dp"
android:theme="@style/TextLabelDummy">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputEditTextNumberDummy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/text_mobile" />

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

It worked fine on my side. Just check it and let me know about it. Thank you.



Related Topics



Leave a reply



Submit