【Android】使用StateListAnimator实现TextSize的Selector
selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorWhite" android:state_checked="true">
<set>
<objectAnimator android:duration="0" android:propertyName="textSize" android:valueFrom="14" android:valueTo="16" android:valueType="floatType" />
</set>
</item>
<item android:color="@color/colorBlack" android:state_checked="false">
<set>
<objectAnimator android:duration="0" android:propertyName="textSize" android:valueFrom="16" android:valueTo="14" android:valueType="floatType" />
</set>
</item>
</selector>
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical”>
<TextView
android:layout_width="wrap_content"
android:layout_height=“wrap_content"
android:stateListAnimator="@drawable/selector.xml"
tools:targetApi="lollipop" />
</LinearLayout>
浙公网安备 33010602011771号