自定义RadioButton 文字在下,图片在上

[html]  view plain copy
  1. <LinearLayout android:id="@+id/status_toolbar"  
  2.     android:layout_width="fill_parent"  
  3.     android:layout_height="wrap_content"  
  4.     android:layout_alignParentBottom="true"  
  5.     android:orientation="horizontal"  
  6.     android:background="@drawable/status_toolbar_bg"  
  7.     android:gravity="center_vertical|center_horizontal"  
  8.     >  
  9.   
  10.     <RadioButton  
  11.         android:background="@android:color/transparent"  
  12.         android:layout_width="wrap_content"  
  13.         android:layout_height="wrap_content"  
  14.         android:button="@null"  
  15.         android:drawableTop="@drawable/status_refresh_selector"  
  16.         android:gravity="center"  
  17.         android:text="刷新"  
  18.         android:layout_weight="1"  
  19.         android:textColor="@color/white" />  
  20.   
  21.        
  22.        <RadioButton android:layout_width="wrap_content"  
  23.         android:layout_height="wrap_content"  
  24.         android:button="@null"  
  25.         android:text="评论"  
  26.         android:gravity="center"  
  27.         android:layout_weight="1"  
  28.        android:background="@android:color/transparent"  
  29.         android:textColor="@color/white"  
  30.         android:drawableTop="@drawable/status_comment_selector"></RadioButton>  
  31.        
  32.        <RadioButton android:layout_width="wrap_content"  
  33.         android:layout_height="wrap_content"  
  34.         android:button="@null"  
  35.         android:text="转发"  
  36.         android:gravity="center"  
  37.         android:layout_weight="1"  
  38.         android:background="@android:color/transparent"  
  39.         android:textColor="@color/white"  
  40.         android:drawableTop="@drawable/status_forward_selector"></RadioButton>  
  41.        
  42.        <RadioButton android:layout_width="wrap_content"  
  43.         android:layout_height="wrap_content"  
  44.         android:button="@null"  
  45.         android:text="收藏"  
  46.         android:gravity="center"  
  47.         android:layout_weight="1"  
  48.         android:background="@android:color/transparent"  
  49.         android:textColor="@color/white"  
  50.         android:drawableTop="@drawable/status_fav_selector"></RadioButton>  
  51.       
  52.        <RadioButton android:layout_width="wrap_content"  
  53.         android:layout_height="wrap_content"  
  54.         android:button="@null"  
  55.         android:text="更多"  
  56.         android:gravity="center"  
  57.         android:layout_weight="1"  
  58.         android:background="@android:color/transparent"  
  59.         android:textColor="@color/white"  
  60.         android:drawableTop="@drawable/status_more_selector"></RadioButton>  
  61.       </LinearLayout>  


关键语句功能:

android:button="@null" 删除原本系统默认在左的选择框

android:background="@android:color/transparent"  去除左边选择框被删除后的空白

android:drawableTop="@drawable/status_more_selector" 选择图片在文字上面

android:gravity="center" 保证文字与图片在平行

android:layout_weight="1" 使每一个RadioButton占的空间一样大

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值