無効なコード
//设置顶部图标
val drawable = resources.getDrawable(align.resId)
setCompoundDrawables(null, drawable, null, null)
有効なコード
- リソース画像を取得するための AppCompatResources.getDrawable
- setBounds を設定する必要があります
//设置顶部图标
val drawable = AppCompatResources.getDrawable(context, align.resId)
drawable?.setBounds(0, 0, drawable.minimumWidth, drawable.minimumHeight)
setCompoundDrawables(null, drawable, null, null)