Skip to content

Instantly share code, notes, and snippets.

@Jeevuz
Created November 18, 2020 11:29
Show Gist options
  • Save Jeevuz/c80bdad7c21c43e62c1c92e319823dd8 to your computer and use it in GitHub Desktop.
Save Jeevuz/c80bdad7c21c43e62c1c92e319823dd8 to your computer and use it in GitHub Desktop.
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.core.content.withStyledAttributes
class MyCustomView(
context: Context,
attrs: AttributeSet? = null
) : View(context, attrs) {
init {
context.withStyledAttributes(attrs, R.styleable.MyCustomView) {
}
}
}
// Also set
// <declare-styleable name="MyCustomView">
// <attr name="someAttribute" format="color"/>
// </declare-styleable>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment