1

I am able to change the color of a floating label for a TextInputLayout that is wrapping an EditText. When it floats up during the animation phase using the below code I am able to select the color black (default is white) using "android:textColor". I am trying to select a different color when the EditText becomes unfocused--meaning when the floated label becomes permanent above the EditText. My minimum API is 14. Please advise.

partial themes.xml file:

<?xml version="1.0" encoding="utf-8"?>

<style name="AppTheme" parent="AppTheme.Base"/>

<style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar" >
...
</style>

<style name="FloatingLabel" parent="@android:style/TextAppearance" >
    <item name="android:textColor">#000000</item>
</style>

partial layout.xml file:

...
<android.support.design.widget.TextInputLayout
    android:id="@+id/ToDo_text_input_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/FloatingLabel"
    >
...
AJW
  • 1,578
  • 3
  • 36
  • 77
  • **Fallow My Answer Below Link** [Change Label Color Link ](http://stackoverflow.com/questions/30546430/how-to-change-the-floating-label-color-of-textinputlayout) – Brahmam Yamani Feb 05 '16 at 11:48

1 Answers1

7

Add this in styles:

<style name="TextAppearence.App.TextInputLayout" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/red</item>
    <item name="android:textSize">14sp</item>
</style>

Add this in your layout:

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

    <android.support.v7.widget.AppCompatEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/hint" />
</android.support.design.widget.TextInputLayout>
Sreeraj P K
  • 100
  • 4