试过了setBounds()发现不可行啊,大神还有没有其他办法
求助啊,谁有解决类似问题的经验
RadioButton[] rbs = new RadioButton[4];
rbs[0] =rb1;
rbs[1] = rb2;
rbs[2] = rb3;
rbs[3] = rb4;
for (RadioButton rb : rbs) {
//挨着给每个RadioButton加入drawable限制边距以控制显示大小
Drawable[] drawables = rb.getCompoundDrawables();
//获取drawables
Rect r = new Rect(0, 0, drawables[1].getMinimumWidth()*2/5, drawables[1].getMinimumHeight()*2/5);
//定义一个Rect边界
drawables[1].setBounds(r);
//给指定的radiobutton设置drawable边界
// if (rb.getId() == R.id.rb_more) {
// r = new Rect(0, 0, drawables[1].getMinimumWidth(), drawables[1].getMinimumHeight());
// drawables[1].setBounds(r);
// }
//添加限制给控件
rb.setCompoundDrawables(null,drawables[1],null,null);
}
new Rect的时候,根据需求可以随意调整图片大小,改变(0, 0, drawables[1].getMinimumWidth()*2/5, drawables[1].getMinimumHeight()*2/5)中的值就行了