Beeing Jk Beeing Jk - 4 months ago 20
Android Question

Android: animation on layout after button clicked for minimum SDK version of 14

How can I do exactly the same effect as this in Android in minimum SDK version 14 application?

enter image description here


  • Background effect

  • slide toggle button

  • my minSDKVersion is 14



Is looks like a circle enlarging animation on background, or is there a more specific function for it?

many thanks...

Answer

Have a look Circular Reveal from touch point:

@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
        if (view.getId() == R.id.square_yellow) {
            revealFromCoordinates(motionEvent.getRawX(), motionEvent.getRawY());
        }
    }
    return false;
}

private Animator animateRevealColorFromCoordinates(int x, int y) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    viewRoot.setBackgroundColor(color);
    anim.start();
}

enter image description here