我想在android中创建一个淡入淡出的动画。对象应围绕 y 轴设置 alpha 动画。这意味着它应该以顺时针方向创建从 0f 到 1f 的 alpha。
我正在使用一个自定义的 ImageView 当然是一个圆圈。
我尝试过使用 ObjectAnimator 类,但没有成功。
我创建了这样的动画淡入淡出:
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);
没有标准的方法可以做到这一点,如果它是自定义视图,您可能必须编写自己的方法来绘制覆盖 ondraw 方法的弧的一部分。