
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,69,69);//第一0是距左右边距离,第二0是距上下边距离,第三69长度,第四宽度 rbWeiHui.setCompoundDrawables(null,drawableWeiHui,null,null);//只放上面 Drawable drawableAdd = getResources().getDrawable(R.drawable.btn_tab_add_selector); drawableAdd.setBounds(0,168,120); rbAdd.setCompoundDrawables(drawableAdd,null); Drawable drawableRight = getResources().getDrawable(R.drawable.btn_tab_mine_selector); drawableRight.setBounds(0,69); rbmine.setCompoundDrawables(null,drawableRight,null); //初始化底部标签 rgGroup.check(R.ID.rb_wei_hui);// 默认勾选首页,初始化时候让首页默认勾选
xml:
<RadioGroup androID:ID="@+ID/re_group" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="@color/app_bg_color" androID:orIEntation="horizontal" > <Radiobutton androID:ID="@+ID/rb_wei_hui" androID:layout_margintop="5dp" androID:drawabletop="@drawable/btn_tab_wei_hui_selector" androID:textSize="12sp" androID:text="xx" /> <Radiobutton androID:ID="@+ID/rb_add" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:background="@color/app_bg_color" androID:button="@null" androID:drawabletop="@mipmap/ic_add_selected" androID:gravity="center" androID:paddingtop="10dip" /> <Radiobutton androID:ID="@+ID/rb_mine" androID:layout_margintop="5dp" androID:drawabletop="@drawable/btn_tab_mine_selector" androID:textSize="12sp" androID:text="xx" /> </RadioGroup>
selected:只写一个selected,其它模仿此
<?xml version="1.0" enCoding="utf-8"?> <selector xmlns:androID="http://schemas.androID.com/apk/res/androID" > <item androID:drawable="@mipmap/ic_mine_selected" androID:state_checked="true" /> <item androID:drawable="@mipmap/ic_mine_normal" /> </selector>
style:共同的style-中间的是定制的,左右一个风格
<!-- 低栏Radiobutton首页下面的标签的样式 --> <style name="BottomTabStyle"> <item name="androID:layout_wIDth">wrap_content</item> <item name="androID:layout_height">wrap_content</item> <item name="androID:layout_gravity">center_vertical</item> <item name="androID:button">@null</item> <item name="androID:padding">5dp</item> <item name="androID:drawablepadding">3dp</item> <item name="androID:textcolor">@drawable/btn_tab_text_selector</item> <item name="androID:layout_weight">1</item> <item name="androID:gravity">center</item> <item name="androID:layout_margintop">5dp</item> </style>
效果:
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
总结以上是内存溢出为你收集整理的Android RadioButton 图片位置与大小实例详解全部内容,希望文章能够帮你解决Android RadioButton 图片位置与大小实例详解所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)