RadioButton的drawableTop头部图片大小设置
设置之前
更改之后
网上也有很多的资料不过多解释
// 最主要代码
RadioButton[] radioButtons = new RadioButton[4];
radioButtons[0] = mainHomeRb;
radioButtons[1] = mainShoppRb;
radioButtons[2] = mainTransactionRb;
radioButtons[3] = mainMineRb;
for (RadioButton rb : radioButtons) {
//挨着给每个RadioButton加入drawable限制边距以控制显示大小
Drawable[] drawables = rb.getCompoundDrawables();
//获取drawables
Rect r = new Rect(0, 0, drawables[1].getMinimumWidth()*2/3, drawables[1].getMinimumHeight()*2/3);
//定义一个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);
也可以参考 一下两篇博客 主要内容差不多
https://blog.csdn.net/qq_36071384/article/details/78475579
https://blog.csdn.net/mmuuchun/article/details/50286209