Android L reveal 效果不工作

标签 android android-5.0-lollipop

我试图在 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/

相关文章:

android - 如何更改过度滚动边缘和过度滚动发光的颜色

Android( Lollipop )EditText onFocus 多次触发

java - 你如何用 asynctask json 做 pojo

android - Android 中 InputMethodManager SHOW_FORCED 和 SHOW_IMPLICIT 的区别

java - 如何从txt中删除行?

java - Android 外部 Jar

android - 如何在android中实现 'Data Tables'( Material 设计组件)?

android - 即使应用程序被用户从后台杀死,如何始终运行后台服务

android - android 5.0 switch 报错

java - Android gradle从多个目录复制到一个.jar