HRJ
HRJ

Reputation: 17767

How to define a shape.xml for RadioButton?

I want to create a custom drawable for RadioButton's button drawable.

I have created a theme and style, which points the RadioButton's button drawable to a custom drawable defined in XML.

The drawable.xml looks like this:

<android:shape xmlns:android="http://schemas.android.com/apk/res/android" shape="oval">
  <android:solid color="#ffffffff"/>
</android:shape>

But this displays a blank area where the button should have been.

I tried adding a size parameter as well:

<android:shape xmlns:android="http://schemas.android.com/apk/res/android" shape="oval">
  <android:solid color="#ffffffff"/>
  <android:size width="16dip" height="16dip" />
</android:shape>

But no luck with that either.

Upvotes: 1

Views: 1742

Answers (1)

HRJ
HRJ

Reputation: 17767

It was a silly mistake on my part! I had missed the android: namespace qualifier on the color and other attributes.

The following works fine:

<android:shape xmlns:android="http://schemas.android.com/apk/res/android" shape="oval">
  <android:solid android:color="#ffffffff"/>
  <android:size android:width="16dip" android:height="16dip" />
</android:shape>

Upvotes: 3

Related Questions