Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android changing TextInputLayout text color

I want to change TextInputLayout float hint text. Here is the solution I tried:

style.xml:

<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/colorPrimary</item>
</style>

layout.xml:

<android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout">

It works fine for some parts of app but not changes the hint color of some activities or fragments. I wonder How is it possible that a piece of code can effect some activities but not on the others.

Any idea?

like image 986
user5510211 Avatar asked Jun 21 '26 14:06

user5510211


2 Answers

Add <item name="colorAccent">@color/theme_color_blue</item> line in your style.xml like this

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorPrimary">@color/theme_color_blue</item>
    <item name="colorAccent">@color/theme_color_blue</item>
    <item name="android:textColorPrimary">@color/colorTextPrimary</item>
    <item name="android:textColorSecondary">@color/colorTextSecondary</item>
</style>
like image 158
Anil Avatar answered Jun 23 '26 05:06

Anil


you should use textColorHint item for your AppTheme style:

<item name="android:textColorHint">@color/yourcolor</item>
like image 20
Mahdi Nouri Avatar answered Jun 23 '26 04:06

Mahdi Nouri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!