Skip to content Skip to sidebar Skip to footer

How To Stop Textinputlayout For Changing Color Of The Endicondrawable And Change The Color Of Underline Only When User Clicks?

Issue-1: TextInputLayout is changing the color of endIconDrawable, it is green and white by default but it is getting changed to grey so how do i stop it? Issue-2: I want to change

Solution 1:

To avoid tinting the endIconDrawable you have to use the app:endIconTint="@null" otherwise the widget will use the default selector:

 <com.google.android.material.textfield.TextInputLayout
    app:endIconTint="@null"

To change the underline color you have to use the boxStrokeColor attribute with a custom selector:

<com.google.android.material.textfield.TextInputLayout
    app:boxStrokeColor="@color/myselector"

with:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:color="?attr/colorPrimary"android:state_focused="true"/>  <-- this line
  <itemandroid:alpha="0.87"android:color="?attr/colorOnSurface"android:state_hovered="true"/><itemandroid:alpha="0.12"android:color="?attr/colorOnSurface"android:state_enabled="false"/><itemandroid:alpha="0.38"android:color="?attr/colorOnSurface"/></selector>

enter image description here

To change the background color use the app:boxBackgroundColor attribute:

    <com.google.android.material.textfield.TextInputLayout
        app:endIconTint="@null"
        app:boxBackgroundColor="@color/bk_selector"

with a selector like:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:alpha="0.16"android:color="?attr/colorOnSurface"android:state_hovered="true"/><itemandroid:alpha="0.12"android:color="?attr/colorOnSurface"android:state_focused="true"/>  <-- this line
  <itemandroid:alpha="0.04"android:color="?attr/colorOnSurface"android:state_enabled="false"/><itemandroid:alpha="0.12"android:color="?attr/colorOnSurface"/></selector>

enter image description here

Post a Comment for "How To Stop Textinputlayout For Changing Color Of The Endicondrawable And Change The Color Of Underline Only When User Clicks?"