Mark Gilchrist
Mark Gilchrist

Reputation: 2032

XMl integer selector Android resource file

I have a requirement to vary the border box on a TextInputLayout, I have a theme that I have applied to all my TextInputLayouts and I want to modify boxStrokeWidth based on state

 <style name="InputTextStyle" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
    <item name="android:textColor">@color/secondary_button_text_selector</item>
    <item name="boxStrokeColor">@color/text_field_border_color</item>
    <item name="boxStrokeWidth">@Integer/my_int_selector </item>
 </style>

is there a way of creating a selector that returns a dimension integer?

something like

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:dimen="1dp" android:state_pressed="true" /> <!-- pressed -->
    <item android:dimen="4dp" android:state_focused="true" /> <!-- focused -->
    <item android:dimen="1dp" android:state_enabled="false" /> <!-- focused -->
    <item android:dimen="1dp" /> <!-- default -->
</selector>

Upvotes: 1

Views: 94

Answers (0)

Related Questions