解决某些手机RadioGroup中的RadioButton不居中(右移)问题
2015-08-23 21:31
525 查看
最近一直在忙一个项目,页面的基本框架类似于QQ那样,有底部导航栏的,遂采用的是RadioButton来实现的。本来一直在我的模拟器上测试,页面展示是没啥问题的,效果图如下:
![](http://img.blog.csdn.net/20150823212258830)
可是,坑爹的事今天却发生了。 测试人员给我说,底部的导航栏图标文字右移,不居中,我的个擦,我一看,心中蹦出了一个鲜亮的词——尼玛,这是啥情况?!右移的图如下:
![](http://img.blog.csdn.net/20150823212734633)
看看,这就是那个坑爹的效果啊。当然,坑爹归坑爹,还得解决啊,遂求助于度娘,发现,居然还有不少人遇到过这个问题,好心人给出了解决方案,只需要在每个RadioButton中,添加一个属性android:paddingLeft="0dp",或者是 android:background="@color/transparent" ,两个方案都可以ok的。
下面给出解决后的布局代码:
可是,坑爹的事今天却发生了。 测试人员给我说,底部的导航栏图标文字右移,不居中,我的个擦,我一看,心中蹦出了一个鲜亮的词——尼玛,这是啥情况?!右移的图如下:
看看,这就是那个坑爹的效果啊。当然,坑爹归坑爹,还得解决啊,遂求助于度娘,发现,居然还有不少人遇到过这个问题,好心人给出了解决方案,只需要在每个RadioButton中,添加一个属性android:paddingLeft="0dp",或者是 android:background="@color/transparent" ,两个方案都可以ok的。
下面给出解决后的布局代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/activity_bg" android:orientation="vertical"> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1.0"></FrameLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioGroup android:id="@+id/radiogroup" android:layout_width="match_parent" android:layout_height="50dip" android:layout_gravity="bottom" android:background="#ffffff" android:gravity="center_vertical" android:orientation="horizontal"> <RadioButton style="@style/navigation_style" android:checked="true" android:drawablePadding="3dp" android:drawableTop="@drawable/selector_main_bottom_tab_first" android:paddingLeft="0dp" android:text="首页" /> <RadioButton style="@style/navigation_style" android:checked="false" android:drawablePadding="3dp" android:drawableTop="@drawable/selector_main_bottom_tab_second" android:paddingLeft="0dp" android:text="唱歌" /> <RadioButton style="@style/navigation_style" android:checked="false" android:drawablePadding="3dp" android:drawableTop="@drawable/selector_main_bottom_tab_third" android:paddingLeft="0dp" android:text="跳舞" /> <RadioButton style="@style/navigation_style" android:checked="false" android:drawablePadding="3dp" android:drawableTop="@drawable/selector_main_bottom_tab_forth" android:paddingLeft="0dp" android:text="我的" /> </RadioGroup> </RelativeLayout> </LinearLayout> </RelativeLayout>
相关文章推荐
- (2.1.22)JDBC为什么要使用PreparedStatement而不是Statement
- SQL操作表数据_删除操作(delete和truncate)
- jvm的类加载器
- 80元,100元,300元,500元低价出售40个不错的老域名
- head first c<11>在根据网络编程
- 阿里云如何做政府的“生意”
- 如何完全退出android应用程序
- "App Timeline Server"重启失败解决办法
- 微信oauth获取用户的信息页面授权
- POJ 2485:Highways(最小生成树&&prim)
- 9.11排序与查找(七)——叠罗汉
- 数据对齐
- Accelerated C++ 学习笔记3
- 微信oauth获取用户的信息页面授权
- 建立TCP连接,实现基本通信
- Unique Paths I II
- Cocos2D游戏之旅(六):流星、烟花、火焰、下雪、下雨粒子特效
- swift详解之九---------------自动引用计数、循环引用(这个必须理解,必须看)
- AwesomeMenu,仿Path主菜单效果
- 对工作和出事方式的三点感悟