Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change underline color and floating hint color of TextInputLayout

I'm using the above property in my TextInputLayout theme to make the underline color of the TextInputLayout green when activated.

      <item name="colorControlActivated">#27e905</item>

Its works fine and I get the following result

enter image description here

But as you can see colorControlActivated also affects the floating hint color. I need a different color for floating hint. Is there any way t do so?

like image 504
doe Avatar asked Jan 27 '23 17:01

doe


2 Answers

Update 2021

You can use this attribute to control the underline color

app:boxStrokeColor="@color/green"
like image 66
Marwa Eltayeb Avatar answered Jan 31 '23 20:01

Marwa Eltayeb


add these styles in styles.xml

  <style name="textInputLayout.GrayLabel"
    parent="Widget.Design.TextInputLayout">
    <item name="hintTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item>
   </style>

    <style name="AppTheme.TextFloatLabelAppearance"         
     parent="TextAppearance.Design.Hint">
    <!-- Floating label appearance here -->
    <item name="android:textColor">@color/YOUR_COLOR</item>
    <item name="android:textSize">@dimen/YOUR_TEXT_SIZE</item>
</style>

and use it like this:-

        <android.support.design.widget.TextInputLayout
            style="@style/textInputLayout.GrayLabel"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dimen_8dp">
like image 44
nik Avatar answered Jan 31 '23 20:01

nik