SupportAnimator animator =
ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(700);
SupportAnimator animator_reverse = animator.reverse();
if (hidden) {
mRevealView.setVisibility(View.VISIBLE);
animator.start();
hidden = false;
} else {
animator_reverse.addListener(new SupportAnimator.AnimatorListener() {
@Override
public void onAnimationStart() {
}
@Override
public void onAnimationEnd() {
mRevealView.setVisibility(View.INVISIBLE);
hidden = true;
}
@Override
public void onAnimationCancel() {
}
@Override
public void onAnimationRepeat() {
}
});
animator_reverse.start();
}
}
// Android LOLIPOP And ABOVE Version
else {
if (hidden) {
Animator anim = android.view.ViewAnimationUtils.
createCircularReveal(mRevealView, cx, cy, 0, radius);
mRevealView.setVisibility(View.VISIBLE);
anim.start();
hidden = false;
} else {
Animator anim = android.view.ViewAnimationUtils.
createCircularReveal(mRevealView, cx, cy, radius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mRevealView.setVisibility(View.INVISIBLE);
hidden = true;
}
});
anim.start();
}
}
将此方法添加到您的活动中:
private void hideRevealView() {
if (mRevealView.getVisibility() == View.VISIBLE) {
mRevealView.setVisibility(View.INVISIBLE);
hidden = true;
}
}
为显示创建一个新的xml布局,称之为reveal_layout.xml并添加:
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
//You can include whatever layout you want here
为了这个工作,您必须将其添加到活动布局的末尾:
android:layout_width="match_parent"
android:layout_height="wrap_content">
希望这可以帮助.