如何为RadioButton定义shape.xml?

时间:2011-05-31 19:45:06

标签: android

我想为RadioButton的button drawable创建一个自定义drawable。

我创建了一个主题和样式,它将RadioButton的按钮指向可用于XML定义的自定义drawable。

drawable.xml看起来像这样:

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

但是这会显示一个按钮应该在的空白区域。

我也尝试添加尺寸参数:

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

但也没有运气。

1 个答案:

答案 0 :(得分:3)

这是我的一个愚蠢的错误!我错过了android:和其他属性上的color命名空间限定符。

以下工作正常:

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