1

I would like to set the color of the hint visible in a TextInputLayout to my custom color (blue one). Unfortunately, what I've achieved so far is this: screen 1

enter image description here

How can I style the hint in my custom color?

That's what I've done so far:

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/police_blue</item>
        <item name="colorPrimaryDark">@color/police_blue_dark</item>
        <item name="colorAccent">@color/police_blue_light</item>

        <item name="android:textColorHint">@color/police_blue_light</item>
        <item name="colorControlNormal">@color/police_blue_light</item>
        <item name="colorControlActivated">@color/police_blue_light</item>
        <item name="colorControlHighlight">@color/police_blue_light</item>
    </style>

layout_file.xml

<android.support.design.widget.TextInputLayout
        android:id="@+id/login_username_wrapper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/login_username"
            android:hint="@string/username_hint"
        />
    </android.support.design.widget.TextInputLayout>
fragon
  • 3,391
  • 10
  • 39
  • 76
  • 1
    Possible duplicate of [Change EditText hint color when using TextInputLayout](http://stackoverflow.com/questions/30824009/change-edittext-hint-color-when-using-textinputlayout) – Tristan Oct 22 '15 at 23:51
  • @TristanWiley None of the solutions in the question you posted worked for me. I've already tried them all... – fragon Oct 23 '15 at 07:41
  • simply add `android:textColorHint="@color/yourColor"` in ` – Rajesh Sep 17 '16 at 06:10

1 Answers1

0

Apply android:background="@drawable/edittext_bg" on your layout

    <EditText
        android:la`enter code here`yout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/login_username"
        android:hint="@string/username_hint"
    />

After under drawable and create the file edittext_bg.xml and put this code inside.

<layer-list>
   <item>
    <shape android:shape="rectangle">
        <!-- Draw a 2dp width border around shape -->
        <stroke`android:color="#ff1e0c"`
           android:width="2dp"
            />
    </shape>
</item>
<!-- Overlap the left, top and right border using background color  -->
<item android:bottom="2dp">
    <shape android:shape="rectangle">
        <solid android:color="#fffbce"/>
    </shape>
</item>

Hope it helps you.

K. Donon
  • 254
  • 2
  • 13