我正在使用 actvityOptionComapat 的 makeclipRevealAnimation 来打开新 Activity ,但我想要圆形来显示效果,但我正在进入正方形。
是否可以实现循环效果?
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());
}
});
}
最佳答案
我正在使用它并且它工作正常。它是用 Kotlin 编写的,但用 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()
}
关于Android makeClipRevealAnimation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43695646/