自定义RadioButton 文字在下,图片在上
16lz
2021-01-23
<LinearLayout android:id="@+id/status_toolbar" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="horizontal" android:background="@drawable/status_toolbar_bg" android:gravity="center_vertical|center_horizontal" > <RadioButton android:background="@android:color/transparent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:drawableTop="@drawable/status_refresh_selector" android:gravity="center" android:text="刷新" android:layout_weight="1" android:textColor="@color/white" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:text="评论" android:gravity="center" android:layout_weight="1" android:background="@android:color/transparent" android:textColor="@color/white" android:drawableTop="@drawable/status_comment_selector"></RadioButton> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:text="转发" android:gravity="center" android:layout_weight="1" android:background="@android:color/transparent" android:textColor="@color/white" android:drawableTop="@drawable/status_forward_selector"></RadioButton> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:text="收藏" android:gravity="center" android:layout_weight="1" android:background="@android:color/transparent" android:textColor="@color/white" android:drawableTop="@drawable/status_fav_selector"></RadioButton> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:text="更多" android:gravity="center" android:layout_weight="1" android:background="@android:color/transparent" android:textColor="@color/white" android:drawableTop="@drawable/status_more_selector"></RadioButton> </LinearLayout>
关键语句功能:
android:button="@null" 删除原本系统默认在左的选择框
android:background="@android:color/transparent" 去除左边选择框被删除后的空白
android:drawableTop="@drawable/status_more_selector" 选择图片在文字上面
android:gravity="center" 保证文字与图片在平行
android:layout_weight="1" 使每一个RadioButton占的空间一样大
更多相关文章
- 自定义progressbar使用图片
- Shape实现圆形图片
- Android 异步加载图片
- android手机中图片的拖拉及浏览功能
- Android studio图片ERROR: 9-patch image xx .9.png malformed
- Android 之 ImageSwitch图片转换器
- Android下图片或按钮等可拖动到任意位置的效果实现源码
- android 处理图片工具
- android ImageView 显示本地图片