我正在试着做一个定制的计时器
这是我的密码这是完美的
问题是我想有内在的影子
公务舱客户计时表延长计时{
private boolean start = false;
private long startTime, elapsedTime;
private float angle = 0f;
private Paint paint, p;
private RectF r;
public CustomChronometer(Context context, AttributeSet attrs) {
super(context, attrs);
paint = new Paint();
paint.setColor(Color.parseColor("#0897ef"));
paint.setStrokeWidth(25);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
// paint.setStrokeCap(Cap.ROUND);
}
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
super.onLayout(changed, left, top, right, bottom);
r = new RectF(left + 30, top + 30, right - 30, bottom - 30);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (start) {
elapsedTime = System.currentTimeMillis();
angle = (elapsedTime - startTime) * 0.006f;
canvas.drawArc(r, 270f, angle, false, paint);
if (angle >= 360) {
startTime = System.currentTimeMillis();
angle = 0f;
}
invalidate();
}
}
@Override
public void start() {
super.start();
start = true;
startTime = System.currentTimeMillis();
}
@Override
public void stop() {
super.stop();
start = false;
}
}
我要求它看起来像这样
最佳答案
paint paint.setColor(Color.parseColor("#0897ef"));
paint.setStrokeWidth(40);
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
paint.setMaskFilter(new BlurMaskFilter(7, Blur.INNER));
此外,应在清单中禁用硬件加速-
关于android - 获取InnerShadow以进行自定义 View ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15929626/