Android RadioButton图片大小设置

原始
在这里插入图片描述
修改后
在这里插入图片描述
关键代码

		RadioButton[] radioButtons = new RadioButton[]{rb1, rb2, rb3, rb4};
        for (RadioButton rb : radioButtons) {
            Drawable[] drawables = rb.getCompoundDrawables();
            Rect r = new Rect(0, 0, dpToPx(this, 10),dpToPx(this, 10));
            drawables[1].setBounds(r);
            rb.setCompoundDrawables(null, drawables[1], null, null);
        }

需要改变大小,改变后边两个参数即可。除了具体数值,也可以用比例drawables[1].getMinimumWidth()*1/2

发布了640 篇原创文章 · 获赞 143 · 访问量 54万+

猜你喜欢

转载自blog.csdn.net/u010356768/article/details/103522124
今日推荐