Skip to content Skip to sidebar Skip to footer

Customize Bounding Box Stroke In Textinputlayout.outlinedbox

I'm trying to change box Stroke Color of com.google.android.material.textfield.TextInputLayout while not focused but there is no attribute for that this is my TextInputLayout code

Solution 1:

To change the box stroke color just use the app:boxStrokeColor attribute in the xml.

 <com.google.android.material.textfield.TextInputLayout
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        app:boxStrokeColor="@color/mySelector"
        ../>

You should use a selector. It is the default:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:color="?attr/colorPrimary"android:state_focused="true"/><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>

You can also use a custom style:

<stylename="MyOutlinedBox"parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox"><itemname="boxStrokeColor">@color/text_input_selector</item></style>

enter image description hereenter image description here

Post a Comment for "Customize Bounding Box Stroke In Textinputlayout.outlinedbox"