Skip to content

Instantly share code, notes, and snippets.

@dcalance
Created December 3, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcalance/6901da6cca5c6a84914f167a52031cab to your computer and use it in GitHub Desktop.
Save dcalance/6901da6cca5c6a84914f167a52031cab to your computer and use it in GitHub Desktop.
override fun onDraw(canvas: Canvas?) {
if(showProgressBar) {
paint.color = backgroundColor1
if(showPercentage) {
canvas!!.drawRect(0f, progressBarSize, width.toFloat() * 0.85f, height.toFloat() / 2f, paint)
val progressWidth = width * (progress / 100) * 0.85f
paint.color = progressBarColor
canvas.drawRect(0f, progressBarSize, progressWidth, height.toFloat() / 2f, paint)
paint.color = percentageColor
paint.textSize = percentageSize
canvas.drawText("${progress.toInt()}%", width.toFloat() - width.toFloat() * 0.10f, height.toFloat() / 2, paint)
} else {
canvas!!.drawRect(width.toFloat() * 0.075f, progressBarSize, width.toFloat() * 0.85f, height.toFloat() / 2f, paint)
val progressWidth = width * (progress / 100) * 0.85f
paint.color = progressBarColor
canvas.drawRect(width.toFloat() * 0.075f, progressBarSize, progressWidth, height.toFloat() / 2f, paint)
}
} else {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment