user5510211
user5510211

Reputation: 317

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?

Upvotes: 3

Views: 1704

Answers (2)

Anil
Anil

Reputation: 1087

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>

Upvotes: 2

Mahdi Nouri
Mahdi Nouri

Reputation: 1389

you should use textColorHint item for your AppTheme style:

<item name="android:textColorHint">@color/yourcolor</item>

Upvotes: 1

Related Questions