android RadioButton image and text(android RadioButton 图片和文字)
问题描述
我正在使用单选按钮创建自定义选项卡主机,工作正常,但现在我需要在顶部显示图标,在图标下方显示文本,
Im using a radio button to create a custom tab host, is working fine, but now I need to show the icon on top and the text underneath the icon,
这就是我现在所拥有的:
this is what I have now:
但这正是我需要的:
这是我的代码:
<RadioButton
android:id="@+id/rad_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@drawable/home_icon"
android:gravity="center"
android:text="Home"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" >
</RadioButton>
<RadioButton
android:id="@+id/rad_1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="Menu"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="VIP"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="About"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
<RadioButton
android:id="@+id/rad_4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:gravity="center"
android:text="Whats On"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" />
</RadioGroup>
所以我将按钮图标设置为:
So im setting the button icon with:
android:button="@null"
android:button="@null"
什么时候是空的
和
android:button="@drawable/home_icon"
android:button="@drawable/home_icon"
对于图标图像,我应该用它来设置图标吗?如何根据需要组织它?[图标在上,文字在下]
for the icon image, should I use this to set the icon? how to organize it as I need it? [icon on top, text bottom]
我尝试了内部布局,但似乎不喜欢它?
I tried with a layout inside , but doesnt seem to like it?
如何做到这一点?
谢谢!
推荐答案
试试这个:用drawableTop显示图标
Try this: use drawableTop to show the icon
<RadioButton
android:id="@+id/rad_home"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@drawable/rad_background"
android:button="@null"
android:drawableTop="@drawable/home_icon"
android:gravity="center"
android:text="Home"
android:textColor="@drawable/text_background"
android:textSize="@dimen/rad_text_size" >
这篇关于android RadioButton 图片和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:android RadioButton 图片和文字


- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01