ToggleButton icon indicating copy to clipboard operation
ToggleButton copied to clipboard

初始化,默认关闭,没画关闭颜色

Open mudao opened this issue 8 years ago • 1 comments

初始化的时候,ondraw中代码不执行,

    if (offLineWidth > 0) {
        final float cy = offLineWidth * 0.5f;
        rect.set(spotX - cy, centerY - cy, endX + cy, centerY + cy);
        paint.setColor(offColor);
        canvas.drawRoundRect(rect, cy, cy, paint);
    }

因为offLineWidth在onlayout中被赋值为0.建议修复.

@Override
protected void onLayout(boolean changed, int left, int top, int right,
    super.onLayout(changed, left, top, right, bottom);

    final int width = getWidth();
    final int height = getHeight();

    radius = Math.min(width, height) * 0.5f;
    centerY = radius;
    startX = radius;
    endX = width - radius;
    spotMinX = startX + borderWidth;
    spotMaxX = endX - borderWidth;
    spotSize = height - 4 * borderWidth;
    spotX = toggleOn ? spotMaxX : spotMinX;
    offLineWidth = 0;

}

可以把这行offLineWidth = 0;改为调用calculateEffect(toggleOn ? 1 : 0);

mudao avatar Mar 19 '16 03:03 mudao

感谢 已解决

liuhao2018 avatar Oct 24 '16 04:10 liuhao2018