Skip to content

дз#135

Open
daniil-kostetsky wants to merge 1 commit into
Otus-Android:masterfrom
daniil-kostetsky:hw-kostetsky
Open

дз#135
daniil-kostetsky wants to merge 1 commit into
Otus-Android:masterfrom
daniil-kostetsky:hw-kostetsky

Conversation

@daniil-kostetsky
Copy link
Copy Markdown

Снимок экрана 2026-02-17 в 18 36 00


val percent = (amount / totalAmount * 100).toInt()
val text = "$percent%"
textPaint.textSize = outerRadius * 0.15f
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это не обязательно делать в onDraw, в нем вообще желательно действий делать по минимуму, он вызывается очень часто


override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val minSize = (resources.displayMetrics.density * 300).toInt()
val width = when (MeasureSpec.getMode(widthMeasureSpec)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут бы желательно учесть паддинги и можно упростить расчет через resolveSize
val desiredWidth = minSize + paddingLeft + paddingRight
val desiredHeight = minSize + paddingTop + paddingBottom

val width = resolveSize(desiredWidth, widthMeasureSpec)
val height = resolveSize(desiredHeight, heightMeasureSpec)

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 this pull request may close these issues.

2 participants