2014-09-13 30 views
2

我正在使用自定義單選按鈕。這是我當前單選按鈕的圖像。正如你所看到的,按鈕比文本低得多。 如何讓他們內聯?如何使單選按鈕和文本內聯

enter image description here

這是繪製的xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 

<item android:drawable="@drawable/checkedradiobutton" android:state_checked="true"/> 
<item android:drawable="@drawable/unchekedradiobutton" android:state_checked="false"/> 

</selector> 
+0

可以設置重力=「中心垂直」爲XML – MHP 2014-09-13 06:34:25

+0

你的單選按鈕,不要在這裏回答@MHP – 2014-09-13 12:35:41

回答

2

使用android:gravity="center"

<RadioButton 
     android:text="@string/day" 
     android:id="@+id/jour"    
     android:gravity="center" 
     android:checked="true"> 
</RadioButton> 

居中文本。

2

,你可以在你的單選按鈕標籤使用重力

<RadioButton 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"  
    android:gravity="center-vertical|right"<!--allow text position in center vertically--> 
    android:button="@null"<!--disable default radio button(it's default position is to the left of text)--> 
    android:drawableRight="@android:drawable/btn_radio"<!--put radioButton to right of text-->> 
</RadioButton> 
相關問題