问题
I know how to set background for my radio button. But I don't know what is the best/right way to change background of selected radio button? Is it possible to make it in xml or has to be done in code?
Regards
回答1:
Just create a selector xml file in drawable folder
checkbox_background.xml
And apply this background to your radio buttons
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/checkbox_background" />
回答2:
You can define a selector for your radio button as described in this answer:
Is it possible to change the radio button icon in an android radio button group
回答3:
Use
android:gravity="center"
for the radio button. This will center the text.
来源:https://stackoverflow.com/questions/6245484/android-radiobutton-background-style-when-selected