【问题标题】:Android - How to create CheckBox drawable?Android - 如何创建 CheckBox 可绘制对象?
【发布时间】:2021-02-15 23:04:33
【问题描述】:
使用CheckBox 时,会为此“检查”图标创建一些Drawable - AnimatedStateListDrawable。有没有办法在没有CheckBox 的情况下以编程方式创建这个drawable?我在 CompoundButton 类中发现的唯一内容就是这个资源 - com.android.internal.R.styleable.CompoundButton_button。
【问题讨论】:
标签:
android
checkbox
android-drawable
【解决方案1】:
找到解决方案:
val attrs = intArrayOf(android.R.attr.listChoiceIndicatorMultiple)
val ta = getContext().theme.obtainStyledAttributes(attrs)
ta.getDrawable(0)
对于 RadioButton,它是 android.R.attr.listChoiceIndicatorSingle。