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

Not able to set stroke_width programmatically #22

Open
jackthebeast opened this issue Sep 10, 2020 · 0 comments · May be fixed by #27
Open

Not able to set stroke_width programmatically #22

jackthebeast opened this issue Sep 10, 2020 · 0 comments · May be fixed by #27

Comments

@jackthebeast
Copy link

I'm extending the class so I don't have to set all the styles every time I use it, but setting stroke width from my sub class doesn't work. Here's my complete class:

class CustomCircleProgressBar(context: Context, attributes: AttributeSet?) : CircleProgressBar(
    context,
    attributes
) {

    constructor(context: Context) : this(context, null)

    init {
        setStyle(SOLID_LINE)
        setProgressStartColor(getContext().getColor(R.color.colorAccent))
        setProgressEndColor(getContext().getColor(R.color.colorAccent))
        setProgressBackgroundColor(getContext().getColor(R.color.colorPrimaryLight))
        setProgressTextColor(getContext().getColor(android.R.color.transparent))
        setProgressStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics()))
    } 
}

the stroke remains 1dp thin.
Works correctly if set from xml: app:progress_stroke_width="5dp"

Other parameters are working correctly. It appears to me that the problem is due to initPaint() not being called after the new width is set.
Any way I can make it work?

@armancodv armancodv linked a pull request Apr 11, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant