Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android makeClipRevealAnimation

I'm using makeclipRevealAnimation of actvityOptionComapat to open new activity but I want circular to reveal effect but I am getting in the square.

Is it possible to get it 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());
            }
        });
    }
like image 283
Ankit Avatar asked Nov 18 '22 22:11

Ankit


1 Answers

I am using this and it works correctly. It is written in Kotlin but you will not have problems to do 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()
}
like image 56
Emmanuel Guther Avatar answered Nov 21 '22 13:11

Emmanuel Guther