Я обнаружил, что не могу снять флажок радиопереключения по умолчанию в селекторе.Я обнаружил, что его можно удалить, присвоив нулевому свойству «button» либо стиль, либо определение самой кнопки.
Вот пример использования стиля.
<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 определяет селектор, который рисует кнопку в ее различных проверенных состояниях.Вот проверенное состояние:
<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>