Android RadioButton 图片位置与大小
Java:
rgGroup = (RadioGroup) findViewById(R.id.re_group); rbWeiHui = (RadioButton) findViewById(R.id.rb_wei_hui); rbAdd = (RadioButton) findViewById(R.id.rb_add); rbMine = (RadioButton) findViewById(R.id.rb_mine); //定义底部标签图片大小 Drawable drawableWeiHui = getResources().getDrawable(R.drawable.btn_tab_wei_hui_selector); drawableWeiHui.setBounds(0, 0, 69, 69);//第一0是距左右边距离,第二0是距上下边距离,第三69长度,第四宽度 rbWeiHui.setCompoundDrawables(null, drawableWeiHui, null, null);//只放上面 Drawable drawableAdd = getResources().getDrawable(R.drawable.btn_tab_add_selector); drawableAdd.setBounds(0, 0, 168, 120); rbAdd.setCompoundDrawables(drawableAdd, null, null, null); Drawable drawableRight = getResources().getDrawable(R.drawable.btn_tab_mine_selector); drawableRight.setBounds(0, 0, 69, 69); rbMine.setCompoundDrawables(null, drawableRight, null, null); //初始化底部标签 rgGroup.check(R.id.rb_wei_hui);// 默认勾选首页,初始化时候让首页默认勾选
xml:
selected:只写一个selected,其它模仿此
<&#63;xml version="1.0" encoding="utf-8"&#63;>
style:共同的style-中间的是定制的,左右一个风格
效果:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!