Android的大号显示效果不工作 [英] Android L reveal Effect is not working

查看:157
本文介绍了Android的大号显示效果不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图执行 createCircularReveal() FloatingButton 。但动画实在是太快了。如何增加动画的持续时间。我试过 setDuration(毫秒),但它不工作。

我跟developer.android.com,定义自定义动画

下面我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.com, 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的大号显示效果不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆