Android动态设置drawableRight

发布时间 2023-04-12 14:23:31作者: 张学涛
Drawable rightDrawable = getResources().getDrawable(R.drawable.icon); //调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示 rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); // left, top, right, bottom 
RadioButton.setCompoundDrawables(null, null, rightDrawable, null); 
// left, top, right, bottom