I am trying to use my xml file to add a drawable to a button so that it gives the bounce affect. It's resting state size should be 1x1. When you click on it, it should go from 1 to 0.75, and then back from 0.75 to 1 so that it looks like a bounce.
I want the default state to basically be nothing (other code causes the default state to get triggered and the bounce will happen when i dont want it to).
So, I need 3 states. 1 for pressed, 1 to go back to the default, and one that is the default.
Is there any other state that I can use so that the button gets smaller, and then bigger again looking like a bounce without using default?
Codes
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item> <!-- default state -->
<set android:ordering="together">
<objectAnimator
android:duration="75"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="1"
android:valueType="floatType" />
<objectAnimator
android:duration="75"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="1"
android:valueType="floatType" />
</set>
</item>
<item android:state_pressed="true"> <!-- pressed state -->
<set android:ordering="together">
<objectAnimator
android:duration="75"
android:propertyName="scaleX"
android:valueFrom="1"
android:valueTo="0.25"
android:valueType="floatType" />
<objectAnimator
android:duration="75"
android:propertyName="scaleY"
android:valueFrom="1"
android:valueTo="0.25"
android:valueType="floatType" />
</set>
</item>
<item android:state_selected="true"> <!-- selected state -->
<set android:ordering="together">
<objectAnimator
android:duration="75"
android:propertyName="scaleX"
android:valueFrom="0.25"
android:valueTo="1"
android:valueType="floatType" />
<objectAnimator
android:duration="75"
android:propertyName="scaleY"
android:valueFrom="0.25"
android:valueTo="1"
android:valueType="floatType" />
</set>
</item>
</selector>
Use these states for default state: