I have a custom view which extends RelativeLayout. I have some custom attrs in attrs.xml
. Is there a way to obtain common android attrs like android:clickable
like we do with custom attributes?
class MyView(context: Context, attributeSet: AttributeSet?): RelativeLayout(context, attributeSet) {
init {
val attrs = context.obtainStyledAttributes(attributeSet, R.styleable.MyView)
if (attrs.getBoolean(android.R.attr.clickable, true)) {
...
}
attrs.recycle()
}
}
This compiler accepts, but it crashed on runtime. Anyone have come across similar use case? I would like to avoid creating duplicate attrs for custom view which are already defined in SDK.