views:

382

answers:

3

Is it possible to add a little bit of space between a RadioButton and the label while still using Android's built-in components? By default the text looks a little scrunched.

<RadioButton android:id="@+id/rb1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:text="My Text"/>

I've tried a couple of things:

  1. Specifying margin and padding seem to add space around the entire element (button and text, together). That makes sense, but doesn't do what I need.

  2. Creating a custom drawable via XML specifying images for the checked and unchecked states, then adding a few extra pixels to the right side of each image. This should work, but now you are stepping outside the default UI. (Not the end of the world, but not ideal)

  3. Add extra whitespace to the beginning of each label. Android seems to trim a leading space character, as in " My String", but specifying unicode U+00A0, as in "\u00A0My String" does the trick. This works, but it seems kinda dirty.

Any better solutions?

A: 

Can't try this right now to verify, but have you tried to see if the attribute android:drawablePadding does what you need?

mbaird
Hm. Gave it a try and it doesn't seem to have any effect in this situation. Thanks for the suggestion, it certainly sounds right from the description: "The padding between the drawables and the text".
allclaws
A: 

I'm having the same problem. It's as if the drawable and text are in two separate layers drawn on top of each other. In my case the drawable is actually covering the first few letters of text.

Kevin
A: 

Not sure if this will fix your problem, but have you tried Radio Button's "Padding left" property with a value of 50dip or more