码迷,mamicode.com
首页 > 其他好文 > 详细

RadioButton 的background属性表现特征

时间:2014-11-25 00:05:27      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   io   ar   color   sp   on   

对于radiaoButton,应该很多人都用过。下面看一个场景

bubuko.com,布布扣    bubuko.com,布布扣

 

上方时radiogroup,细致观察发现左1,文字开始位置和右1文字开始位置不同,这是为何呢?

查看布局:

<RadioButton
            android:layout_width="0dp"
            android:layout_weight="1.0"
            android:layout_height="match_parent"
            android:button="@null"
            android:gravity="center"
            android:text="@string/guide_video_safe"
            style="@style/text_middle1_size"
            android:textColor="@drawable/textview_selector"
            android:singleLine="true"
            />
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1.0"
            android:layout_height="match_parent"
            android:button="@null"
            android:gravity="center"
            android:text="@string/guide_video_maintain"
            style="@style/text_middle1_size"
            android:textColor="@drawable/textview_selector"
            android:singleLine="true"
            />
        <RadioButton
            android:layout_width="0dp"
            android:layout_weight="1.0"
            android:layout_height="match_parent"
            android:button="@null"
            android:gravity="right|center_vertical"
            android:text="@string/guide_video_emergency"
            style="@style/text_middle1_size"
            android:textColor="@drawable/textview_selector"
            android:singleLine="true"
            />
  <...>
</RadioGroup>


发现并无什么特别,

style定义如下:

 <style name="text_middle1_size">
        <item name="android:textSize">15sp</item>
    </style>

那么问题就来了,造成左右区别的到底是哪个属性?
原来这里我们通过设置background可以使得文字的开始位置从最左边开始。

 

RadioButton 的background属性表现特征

标签:android   style   blog   http   io   ar   color   sp   on   

原文地址:http://www.cnblogs.com/xilinch/p/4119753.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!