我试图在 FloatingButton
中实现 createCircularReveal()
。但是动画太快了。如何增加动画的持续时间。我尝试了 setDuration(milli-seconds)
,但它不起作用。
我关注 developer.android.com,Defining Custom Animations
这是我的代码:
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();
最佳答案
我也遇到了我提到的问题,我可以通过让 cx 和 cy 成为 ImageView 的中心位置来解决这个问题(在你的情况下,我认为它是按钮)。
所以使用这个获取 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;
关于Android L reveal 效果不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27518327/