设置setCompoundDrawables不生效时,是因为没有指定drawable的大小
val drawable=resources.getDrawable(R.mipmap.icon)
drawable.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)//设置drawable大小
text.setCompoundDrawables(drawable, null, null, null)
另外调用setCompoundDrawablesWithIntrinsicBounds也可以解决
text.setCompoundDrawablesWithIntrinsicBounds(resources.getDrawable(R.mipmap.icon), null, null, null)