Skip to content

Instantly share code, notes, and snippets.

@bitvale
Created November 22, 2018 20:15
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/c6b2150971d4a430211a89857b61f64b to your computer and use it in GitHub Desktop.
Save bitvale/c6b2150971d4a430211a89857b61f64b to your computer and use it in GitHub Desktop.
For Medium article "Android Dynamic Custom View is Easy"
private var iconProgress = 0f
set(value) {
if (field != value) {
field = value
val iconOffset = lerp(0f, iconRadius - iconCollapsedWidth / 2, value)
iconRect.left = width - switcherCornerRadius - iconCollapsedWidth / 2 - iconOffset
iconRect.right = width - switcherCornerRadius + iconCollapsedWidth / 2 + iconOffset
postInvalidateOnAnimation()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment