Skip to content Skip to sidebar Skip to footer

Android Scale Button On Touch

I know how to scale the button to a determinated value, but is there a way to increase/decrease the button size per time as long the user is touching it? Something like this: Butto

Solution 1:

Try the following:

@OverridepublicbooleanonTouch(View v, MotionEvent motionEvent) {
    intaction= motionEvent.getAction();
    if (action == MotionEvent.ACTION_DOWN) {
        v.animate().scaleXBy(100f).setDuration(5000).start();
        v.animate().scaleYBy(100f).setDuration(5000).start();
        returntrue;
    } elseif (action == MotionEvent.ACTION_UP) {
        v.animate().cancel();
        v.animate().scaleX(1f).setDuration(1000).start();
        v.animate().scaleY(1f).setDuration(1000).start();
        returntrue;
    }

    returnfalse;
}

This should do the trick ;)

Solution 2:

Post a Comment for "Android Scale Button On Touch"