Skip to content

Instantly share code, notes, and snippets.

@bitvale
Created November 22, 2018 20:17
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 bitvale/3f69a9afb4599fab6d9699d4f73a1d88 to your computer and use it in GitHub Desktop.
Save bitvale/3f69a9afb4599fab6d9699d4f73a1d88 to your computer and use it in GitHub Desktop.
For Medium article "Android Dynamic Custom View is Easy"
override fun onDraw(canvas: Canvas ?) {
// draw switcher (green rect)
canvas?.drawRoundRect(switcherRect, switcherCornerRadius, switcherCornerRadius, switcherPaint)
// draw icon (white rect)
canvas?.withTranslation(x = iconTranslateX) {
drawRoundRect(iconRect, switcherCornerRadius, switcherCornerRadius, iconPaint)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment