2015-11-13 53 views
-1

我想隐藏View,从x,y坐标开始并向外展开此隐藏动画。这可能吗?你怎么能在视图上做一个循环展开隐藏? (与圆形显示相反)

基本上,这是一个圆形显示的相反。我很好这是一个minSdk 21

enter image description here

额外的细节

我有ActivityB(用半透明背景)上的ActivityA顶部。 AcitivityA已经被创建,但它对用户还不可见。当您单击右下角的DONE按钮,我想通过隐藏ActivityB透露ActivityA(使用扩展的圆形隐藏动画,它开始,在用户按下按钮。)

回答

2

你以相反的方式思考这个问题。你说你想隐藏Activity B,但是你同时显示Activity A
这就像看着一个半空的玻璃。它是半满的,半空的。两者都是事实。

试试这个:
显示Activity B。点击完成后,显示Activity A(带有透明背景)并开始显示动画。

但是,如果你坚持隐藏部分,这是如何做到这一点。

View myView = findView(R.id.awesome_card); 

// get the center for the clipping circle 
int cx = (myView.getLeft() + myView.getRight())/2; 
int cy = (myView.getTop() + myView.getBottom())/2; 

// get the final radius for the clipping circle 
int dx = Math.max(cx, myView.getWidth() - cx); 
int dy = Math.max(cy, myView.getHeight() - cy); 
float finalRadius = (float) Math.hypot(dx, dy); 

SupportAnimator animator = 
     ViewAnimationUtils.createCircularReveal(myView, cx, cy, finalRadius, 0); 
animator.setInterpolator(new AccelerateDecelerateInterpolator()); 
animator.setDuration(1500); 
animator.start(); 

而不是从0开始,从finalRadius开始。
我建议为所有活动使用透明背景以避免出于性能目的使用OVERDRAW
对于试图在Pre-Lollipop设备上实现循环显示的其他用户,这是正确的库(CircularReveal)。在预棒棒糖上,它使用自己的实现。在棒棒糖和以上,它使用本机实现。

相关问题