解决某些手机RadioGroup中的RadioButton不居中问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了解决某些手机RadioGroup中的RadioButton不居中问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3073字,纯文字阅读大概需要5分钟。
内容图文
公司的一个项目,一直都在红米1S上做界面,一天为了看下分辨率适配,在一台中兴U819上调试了下程序,结果发现原先居中对齐的底部栏按钮,现在都向右偏移了..截图大概如下:
布局是这么写的:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/app_base_bg" android:orientation="horizontal" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#eeeeee" > <include android:id="@+id/id_ll_main_title" layout="@layout/layout_base_title" /> <android.support.v4.view.ViewPager android:id="@+id/id_vp_main" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/id_line_tab_top" android:layout_below="@+id/id_ll_main_title" /> <View android:id="@+id/id_line_tab_top" android:layout_width="match_parent" android:layout_height="1dp" android:layout_above="@+id/id_ll_main_bottom" android:background="@color/tab_line" /> <LinearLayout android:id="@+id/id_ll_main_bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@color/white" android:gravity="center" android:orientation="horizontal" > <RadioGroup android:id="@+id/main_tab_group" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="horizontal" android:paddingTop="2.0dip" > <RadioButton android:id="@+id/id_rb_main_mine" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:checked="true" android:drawableTop="@drawable/tab_btn_mine_selector" android:gravity="center" android:text="我" android:textColor="@color/tab_btn_text_color_selector" android:textSize="15sp" /> <RadioButton android:id="@+id/id_rb_main_discovery" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawableTop="@drawable/tab_btn_discovery_selector" android:gravity="center" android:text="发现" android:textColor="@color/tab_btn_text_color_selector" android:textSize="15sp" /> <RadioButton android:id="@+id/id_rb_main_commend" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawableTop="@drawable/tab_btn_commend_selector" android:gravity="center" android:text="推荐" android:textColor="@color/tab_btn_text_color_selector" android:textSize="15sp" /> </RadioGroup> </LinearLayout> </RelativeLayout> </LinearLayout>在红米1S中一直都是居中显示,而且在RadioButton中也使用了android:gravity="center"使其图片文字居中,但在中兴手机却偏移了,非常奇怪,难道是分辨率问题,想想不可能吧..然后找了度娘才知道,参考:http://www.eoeandroid.com/thread-273181-1-1.html
网上说,只需要添加一个属性:android:paddingLeft="0dp"就可以,还有人说设置下背景即可,自己试了下,在RadioButton中设置属性android:paddingLeft="0dp"或者android:background="@color/transparent"都可以让按钮居中,两个使用其中之一就可以了。
居中后的截图:
原文:http://blog.csdn.net/myatlantis/article/details/41747567
内容总结
以上是互联网集市为您收集整理的解决某些手机RadioGroup中的RadioButton不居中问题全部内容,希望文章能够帮你解决解决某些手机RadioGroup中的RadioButton不居中问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。