我想在我的应用中使用Reveal Effect。我开始了解它是如何实现的。我从Andoid Developer Blog获得了信息。
但是当我在我的代码中更新它时,它没有显示任何效果。
我也尝试使用Demo given by Google来展示显露效果。但它也没有显示出效果。如果我需要添加任何权限,或者我正在做什么错误?
我的动画师如下:
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;
}
});
请告诉我如何达到这个效果。
答案 0 :(得分:0)
并非Lollipop引入的所有东西都被移植了。揭示,波纹和高度是一些例子。主要原因是其中一些很大程度上依赖于新UI Thread
引入的whit ART
。您可以在最底层的常见问题部分找到更多信息here