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:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="?attr/colorOnSurface" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="?attr/colorOnSurface"/>
</selector>
You can also use a custom style:
<style name="MyOutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeColor">@color/text_input_selector</item>
</style>
Post a Comment for "Customize Bounding Box Stroke In TextInputLayout.OutlinedBox"