Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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