天天看點

Android 圓形展開動畫

在安卓5.0上的material design上的View圓形展開的動畫,主要是依靠  

view.ViewAnimationUtils.createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius)
           

來實作的。 參數的各個含義看名字就知道了,話說動态效果圖怎麼上。。。誰能告訴我  。。。

 貼一下我的源碼:

public void  roundLoad(View myView){
    	int cx = (myView.getLeft() + myView.getRight()) / 2;
    	int cy = (myView.getTop() + myView.getBottom()) / 2;

    	// get the final radius for the clipping circle
    	int finalRadius = Math.max(myView.getWidth(), myView.getHeight());
    	animatorSet=new AnimatorSet();
    	// create the animator for this view (the start radius is zero)
    	Animator anim =
    	    ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
    	anim.setDuration(1000);
    	anim.setInterpolator(new AccelerateInterpolator());
    	
    	Animator anim1 =ObjectAnimator.ofFloat(myView, "translationZ", 0f,50f);
    	anim1.setDuration(1500);
    	anim1.setInterpolator(new AccelerateInterpolator());
    	
    	animatorSet.play(anim).with(anim1);	
    	// make the view visible and start the animation
    	myView.setVisibility(View.VISIBLE);
    	animatorSet.start();
    }