Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mudao opened this issue Mar 19, 2016 · 1 comment
Open

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

mudao opened this issue Mar 19, 2016 · 1 comment

Comments

@mudao
Copy link

mudao commented Mar 19, 2016

初始化的时候,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);

@liuhao2018
Copy link

感谢 已解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants