Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 972
Beeing Jk Avatar asked Nov 24 '15 04:11

Beeing Jk


People also ask

When to use MotionLayout?

MotionLayout is intended to move, resize, and animate UI elements with which users interact, such as buttons and title bars. Motion in your app should not be simply a gratuitous special effect in your application. It should be used to help users understand what your application is doing.

What is minimum SDK version Android?

minSdkVersion is the minimum version of the Android operating system required to run your application. The Android app must have a minimum SDK version 19 or higher. If you want to support devices below API level 19, you must override minSDK version.

How can I tell if an android button is clicked?

If you have more than one button click event, you can use switch case to identify which button is clicked. Link the button from the XML by calling findViewById() method and set the onClick listener by using setOnClickListener() method. setOnClickListener takes an OnClickListener object as the parameter.


4 Answers

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

like image 82
Pratik Butani Avatar answered Oct 12 '22 06:10

Pratik Butani


I don't have concrete examples for exactly what you display in your example, however here are some examples that you can use to get close:

You can use a simple ToggleButton for the switch. See here: http://developer.android.com/guide/topics/ui/controls/togglebutton.html

For the ripple animation, take a look at this post: https://stackoverflow.com/a/26604471/1738090 There are several examples there which display a "ripple" effect. You could easily reuse this animation, decrease the opacity and set the animation to the background of the bigger views as shown in your example.

Hope this helps!

like image 35
w3bshark Avatar answered Oct 12 '22 06:10

w3bshark


You can refer to this library Material Animation library for implementing background reveal animation and Toggle Button library for checkbox animations.

like image 40
Nigam Patro Avatar answered Oct 12 '22 07:10

Nigam Patro


For anyone that is interested, I went ahead and created a demo app to demonstrate this effect using circular reveal from two switches. You can download it here. It's API 21 and above however.

https://github.com/o4wcoder/CircularRevealDemo

like image 1
Chris Hare Avatar answered Oct 12 '22 06:10

Chris Hare