I have these buttons here and i want them both to have some animation onclick. To grow up a little bit and then return to normal.
Here are the buttons xml codes.
<ImageButton
android:layout_width="165dp"
android:layout_height="60dp"
android:text="next"
android:id="@+id/next"
android:src="@drawable/next"
android:background="@android:color/transparent"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/linearLayout"
android:layout_alignEnd="@+id/linearLayout" />
<ImageButton
android:layout_width="170dp"
android:layout_height="60dp"
android:text="confirm"
android:src="@drawable/confirm"
android:background="@android:color/transparent"
android:id="@+id/confirm"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
/>
These buttons are on one activity_main.xml file.
Can someone help me showing me some stuff of what should i do to make it happen?
Thanks a lot for your time.
Use Animator can achieve the goal easily:
findViewById(R.id.next).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Animator scale = ObjectAnimator.ofPropertyValuesHolder(v,
PropertyValuesHolder.ofFloat(View.SCALE_X, 1, 1.5f, 1),
PropertyValuesHolder.ofFloat(View.SCALE_Y, 1, 1.5f, 1)
);
scale.setDuration(1000);
scale.start();
}
});
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