我真正想要的是一个动画,一个带有效果的弧线看起来像是从天空落下的流星,你可以看到LG G3上的动画'圆形小窗口,每次关闭的情况下,动画在戒指周围发光,查看此视频,来自youtube(你可以在00:18,00:30,01:18,01:29 ......看到它) :
https://www.youtube.com/watch?v=tEQpYms1bJA
我做了一些搜索,并编写了我的代码(参考this),但绘制弧线的线条看起来很结实,没有我想要的效果,这是我的圆弧绘图代码:
public class SideArcsView extends View{
private Paint mPaint;
private int parentWidth;
private int strokeWidth;
private RectF oval;
private static int INITIAL_LEFT_ARC_START_ANGLE = 225;
private static int INITIAL_RIGHT_ARC_START_ANGLE = 315;
private int startLeftArcAngle = INITIAL_LEFT_ARC_START_ANGLE;
private int startRightArcAngle = INITIAL_RIGHT_ARC_START_ANGLE;
private int arcAngle = 45;
public SideArcsView(Context mContext, int parentWidth) {
super(mContext);
this.parentWidth = parentWidth;
init();
}
private void init() {
strokeWidth = (12 * parentWidth) / 300;
initPaint();
initOval();
}
private void initPaint() {
mPaint = new Paint();
mPaint.setColor(Color.WHITE);
mPaint.setStrokeWidth(strokeWidth);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setAntiAlias(true);
mPaint.setStrokeCap(Paint.Cap.ROUND);
}
private void initOval() {
float padding = mPaint.getStrokeWidth() / 2;
oval = new RectF();
oval.set(padding, padding, parentWidth - padding, parentWidth - padding);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawArcs(canvas);
}
private void drawArcs(Canvas canvas) {
canvas.drawArc(oval, startLeftArcAngle, arcAngle, false, mPaint);
canvas.drawArc(oval, startRightArcAngle, -arcAngle, false, mPaint);
}
public void startRotateAnimation() {
ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 136);
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.setDuration(2000);
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
startLeftArcAngle = INITIAL_LEFT_ARC_START_ANGLE - (int) animation.getAnimatedValue();
startRightArcAngle = INITIAL_RIGHT_ARC_START_ANGLE + (int) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.start();
}
public void startResizeDownAnimation() {
ValueAnimator valueAnimator = ValueAnimator.ofInt(45, 10);
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.setDuration(2000);
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
arcAngle = (int) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.start();
}
}
看起来像:
有人可以告诉我如何绘制LG G3的发光圈戒指吗?请给我一些建议......