Skip to content

Instantly share code, notes, and snippets.

@PhongHuynh93
Last active July 21, 2021 02:23
Show Gist options
  • Save PhongHuynh93/e146c537ccbd2c95a5d64716572800df to your computer and use it in GitHub Desktop.
Save PhongHuynh93/e146c537ccbd2c95a5d64716572800df to your computer and use it in GitHub Desktop.
Skeleton Structure of TikTokButton
// 1: Create skeleton structure in OnDraw() method
override fun onDraw(canvas: Canvas) {
canvas.drawBitmap(bitmapOfThisView, 0f, 0f, paint)
}
private fun getRightPaint() = paint.apply {
color = rightColor
}
private fun getLeftPaint() = paint.apply {
color = leftColor
}
private fun getCenterPaint() = paint.apply {
color = centerColor
}
private val bitmapOfThisView by lazy {
// 2: Create bitmap which has the same size as the view
// 3: Draw the right part
// 4: Draw the center part
// 5: Draw the left part
// 6: Draw the plus icon
// 7: clear the PorterDuffXfermode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment