How can I do exactly the same effect as this in Android in minimum SDK version 14 application?
Is looks like a circle enlarging animation on background, or is there a more specific function for it?
many thanks...
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.
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.
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.
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();
}
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!
You can refer to this library Material Animation library for implementing background reveal animation and Toggle Button library for checkbox animations.
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
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