我试图执行 createCircularReveal()在 FloatingButton 。但动画实在是太快了。如何增加动画的持续时间。我试过 setDuration(毫秒),但它不工作。
我跟developer.android,定义自定义动画
下面我code:
INT CX =(fabBtn.getLeft()+ fabBtn.getRight())/ 2; INT CY =(fabBtn.getTop()+ fabBtn.getBottom())/ 2; INT finalRadius = Math.max(fabBtn.getWidth(),fabBtn.getHeight()); 动画动画= ViewAnimationUtils.createCircularReveal(fabBtn,CX,CY,2,finalRadius); anim.setDuration(2000); fabBtn.setVisibility(View.VISIBLE); anim.start();解决方案
我也面临这个问题,因为我提到的,我能够通过让CX来解决这个问题,CY的图像视图的中心位置(在你的情况我认为这是按钮)。 因此,让CX和CY使用这样的:
INT CX =(fabBtn.getWidth())/ 2; INT CY =(fabBtn.getHeight())/ 2;
取而代之的是::
INT CX =(fabBtn.getLeft()+ fabBtn.getRight())/ 2; INT CY =(fabBtn.getTop()+ fabBtn.getBottom())/ 2;I tried to implement createCircularReveal() in FloatingButton. But the animation is too fast. How to increase the duration of the Animation. I tried setDuration(milli-seconds), But its not working.
I follow developer.android, Defining Custom Animations
Here my code:
int cx = (fabBtn.getLeft() + fabBtn.getRight()) / 2; int cy = (fabBtn.getTop() + fabBtn.getBottom()) / 2; int finalRadius = Math.max(fabBtn.getWidth(), fabBtn.getHeight()); Animator anim = ViewAnimationUtils.createCircularReveal(fabBtn, cx, cy, 2, finalRadius); anim.setDuration(2000); fabBtn.setVisibility(View.VISIBLE); anim.start();解决方案
I am also facing the issue as I mentioned and I am able to resolve this issue by getting cx and cy the center position for image view (In your case I think it is button). So get cx and cy using this:
int cx = (fabBtn.getWidth()) / 2; int cy = (fabBtn.getHeight()) / 2;Instead of this::
int cx = (fabBtn.getLeft() + fabBtn.getRight()) / 2; int cy = (fabBtn.getTop() + fabBtn.getBottom()) / 2;
更多推荐
Android的大号显示效果不工作
发布评论