Android makeClipRevealAnimation

I am using makeclipRevealAnimation on actvityOptionComapat to open a new activity, but I want the circular to show the effect, but I am getting squared.

Can you get this circular effect?

button.setOnClickListener(new View.OnClickListener() {
            @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,SecActivity.class);
                ActivityOptionsCompat activityOptionsCompat=
                        ActivityOptionsCompat.makeClipRevealAnimation(button,
                                button.getMeasuredWidth(),button.getMeasuredWidth(),
                                   relativeLayout.getWidth(),relativeLayout.getHeight());
                startActivity(intent,activityOptionsCompat.toBundle());
            }
        });
    }

      

+5


source to share


1 answer


I am using this and it works correctly. It is written in Kotlin, but you will have no problem doing it in Java.



//Start an activity from a specific point with reveal animation.
fun revealBundle(v: View): Bundle? {
    var opts: ActivityOptions? = null
    when {
        Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
            val left = 0
            val top = 0
            val width = v.measuredWidth
            val height = v.measuredHeight
            opts = ActivityOptions.makeClipRevealAnimation(v, left, top, width, height)
        }
        Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP -> opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.measuredWidth, v.measuredHeight)
    }
    return  opts?.toBundle()
}

      

0


source







All Articles