1
我有一个ImageView
背景设置为drawable.circle。圆圈的行程宽度很大。我希望将该笔画宽度设置为在指定的持续时间内将其设置为1dp以缩小。如果这不能用drawable完成,我也有一个customView,该路径是一个将paint.style设置为Stroke的圆。我想将该动画应用于drawable.circle或customView。如何动画视图的笔划宽度
CustomCirleView:
public class CustomCircle extends View {
private Path path;
private Paint paint;
float customStrokeWidth = 80;
public float getCustomStrokeWidth() {
return customStrokeWidth;
}
public void setCustomStrokeWidth(float customStrokeWidth) {
this.customStrokeWidth = customStrokeWidth;
}
public CustomCircle(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
path = new Path();
paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setColor(Color.parseColor("#FC6C2B"));
paint.setStrokeWidth(customStrokeWidth);
path.addCircle(getMeasuredWidth()/2, getMeasuredHeight()/2, (getMeasuredWidth()/2)-customStrokeWidth, Path.Direction.CW);
canvas.drawPath(path, paint);
}
}
感谢
动画矢量绘图资源让您动画笔画宽度。如果需要对动画进行更精确的控制,您可以创建自定义绘图并为其创建动画,则它将比自定义View更加分离。 – BladeCoder