I want to have Reveal Effect with in my app. I come to know about it for how it can be implemented. I got the information from the Andoid Developer Blog.
But when i have updated that with in my code, it is not showing any effect.
I have also try with Demo given by Google to demostrate Reveal effect. But it also not showing the effect. If there any permission i need to add or whats wrong i am doing?
My animator is as below:
View button = rootView.findViewById(R.id.button);
final View shape = rootView.findViewById(R.id.circle);
shape.setClipToOutline(false);
shape.setVisibility(View.INVISIBLE);
// Set a listener to reveal the view when clicked.
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(isShowing==false){
// previously invisible view
// get the center for the clipping circle
int cx = (shape.getLeft() + shape.getRight()) / 2;
int cy = (shape.getTop() + shape.getBottom()) / 2;
// get the final radius for the clipping circle
int finalRadius = Math.max(shape.getWidth(), shape.getHeight());
// create the animator for this view (the start radius is zero)
Animator anim =
ViewAnimationUtils.createCircularReveal(shape, cx, cy, 0, finalRadius);
// make the view visible and start the animation
shape.setVisibility(View.VISIBLE);
anim.setDuration(4000);
anim.start();
}else{
// get the center for the clipping circle
int cx = (shape.getLeft() + shape.getRight()) / 2;
int cy = (shape.getTop() + shape.getBottom()) / 2;
// get the initial radius for the clipping circle
int initialRadius = shape.getWidth();
// create the animation (the final radius is zero)
Animator anim =
ViewAnimationUtils.createCircularReveal(shape, cx, cy, initialRadius, 0);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
shape.setVisibility(View.INVISIBLE);
}
});
anim.setDuration(4000);
// start the animation
anim.start();
}
isShowing = !isShowing;
}
});
Please let me know how to achieve this effect.
Not everything that was introduced with Lollipop was backported. Reveal, ripple and elevation are some examples. The main reason is that some of them rely heavily on the new
UI Thread
introduced whitART
. You can find more info here, on the very bottom, in the faq section