Obtain drawable from ?android:attr programatically

84 Views Asked by At

I want to create RadioButton programatically and set drawable End using resource from ?android:attr. The equivalent in xml is this:

android:drawableEnd="?android:attr/listChoiceIndicatorSingle"

I have tried using typedValue to retrieve it in activity but always resource not found. This is my code:

val tv = TypedValue().also {
    theme.resolveAttribute(com.google.android.material.R.attr.listChoiceIndicatorSingleAnimated, it, true)
}
val drawable = ContextCompat.getDrawable(this, tv.resourceId)

Is it possible to do this?

0

There are 0 best solutions below