I use a selector and I do not know how to set text size. Maybe I'm doing something wrong - help
arrow.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed" android:state_pressed="true" android:color="@color/green"></item>
</selector>
You can use an selector under animator resources:
<!-- res/animator/text_size.xml -->
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<set>
<objectAnimator
android:duration="0"
android:propertyName="textSize"
android:valueTo="18sp"
android:valueType="floatType"/>
</set>
</item>
<item android:state_focused="false">
<set>
<objectAnimator
android:duration="0"
android:propertyName="textSize"
android:valueTo="10sp"
android:valueType="floatType"/>
</set>
</item>
</selector>
You can have 0 duration for jumping straight to the value or put a duration in there.
Then to use it set android:stateListAnimator
on your view:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"
android:stateListAnimator="@animator/text_size"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With