mohsen
mohsen

Reputation: 461

How to make radiobutton button and text inline

I'm using custom radiobutton . this is the image of my current radiobutton . as you can see , the button is much lower then the text . How can I make them inline ?

enter image description here

this is the drawable 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>

Upvotes: 2

Views: 431

Answers (2)

MHP
MHP

Reputation: 2731

you can use gravity in your RadioButton tag

<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>

Upvotes: 2

Nadeem Iqbal
Nadeem Iqbal

Reputation: 2374

Use android:gravity="center"

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

to center your text.

Upvotes: 2

Related Questions