【问题标题】:Android fade in animationAndroid淡入动画
【发布时间】:2013-08-19 07:23:49
【问题描述】:

我想在 android 中创建一个淡入淡出的动画。对象应围绕 y 轴设置 alpha 动画。这意味着它应该以顺时针方向创建从 0f 到 1f 的 alpha。

我正在使用一个自定义的 ImageView,当然这是一个圆圈。

我尝试过使用 ObjectAnimator 类,但没有成功。

【问题讨论】:

    标签: android animation alpha


    【解决方案1】:

    我创建了这样的淡入淡出动画:

    Handler handler = new Handler();
    
        Animation fadeIn = new AlphaAnimation(0, 1);
                fadeIn.setInterpolator(new DecelerateInterpolator()); //add this
                fadeIn.setDuration(2000);
    
                Animation fadeOut = new AlphaAnimation(1, 0);
                fadeOut.setInterpolator(new AccelerateInterpolator()); //and this
                fadeOut.setStartOffset(1000);
                fadeOut.setDuration(1000);
    
                AnimationSet animation = new AnimationSet(false); //change to false
                animation.addAnimation(fadeIn);
                //animation.addAnimation(fadeOut);
                logo.setAnimation(animation);
    

    【讨论】:

    • 不,这不是我需要的。第一个问题是我不能使用 Animation 对象,因为我已经创建了一个自定义 ImageView,它已经使用动画进行倾斜,唯一有效的是 ObjectAnimator 类。第二件事是我希望圆圈顺时针淡入。我不希望整个图像立即出现。它需要一点一点地褪色
    【解决方案2】:

    没有标准的方法可以做到这一点,如果它是自定义视图,您可能必须编写自己的方法来绘制覆盖 ondraw 方法的弧的一部分。

    【讨论】:

      猜你喜欢
      • 2014-10-24
      • 2011-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-18
      • 2011-10-11
      • 1970-01-01
      相关资源
      最近更新 更多