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 图片和文字
基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
