remove default radio button checkbox when using a custom selector

Set the button value to null in layout XML

android:button="@null"

I found that I cannot remove the default radiobutton checkbox in the selector. I found that it can be removed by assigning the "button" property to null, in either the style or the definition of the radiobutton itself.

Here is an example using a style.

<RadioButton
    android:id="@+id/myRadioButton"
    style="@style/RadioButtonStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/custom_radio_button"/>

<style name="RadioButtonStyle" parent="@android:style/Widget.CompoundButton">
    <item name="android:background">@drawable/radiobutton_selector</item>
    <item name="android:button">@null</item>
</style>

radiobutton_selector defines a selector that draws the button in its different checked states. Here is the checked state:

<item android:state_checked="true">
    <shape>
        <gradient
            android:startColor="@color/titleButtonCheckedGradientLight"
            android:centerColor="@color/titleButtonCheckedGradientDark"
            android:endColor="@color/titleButtonCheckedGradientDark"
            android:angle="270" />
        <stroke
            android:width="1dp"
            android:color="@color/titleButtonBorder" />
        <corners
            android:radius="5dp" />
    </shape>
</item>