问题
I want to show a radio list inside an AlertDialog with custom styling, something like .
So I created a custom theme and provided that as an argument to AlertDialog.Builder's constructor.
Here's the code for showing the dialog :
private void showSortDialog() {
final CharSequence[] options = new String[] {"Relevance", "Newest"};
AlertDialog.Builder builder = new AlertDialog.Builder(getActivityReference(),
R.style.RadioDialogTheme);
builder.setTitle("Sort by");
builder.setSingleChoiceItems(options, -1, new DialogInterface.OnClickListener() {
. . . .
builder.create().show();
}
Here's the style :
<style name="RadioDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColorAlertDialogListItem">@drawable/radiobutton_textcolor_selector
</item>
<item name="android:listChoiceIndicatorSingle">@drawable/apptheme_btn_radio_holo_light
</item>
</style>
I was able to find a couple of attributes which I added in my style to change the color of the radio button / text based on their state. But I'm not able to customize the text appearance (I want to change the size, provide padding etc).
I'm sure there is some attribute using which I can style the text but I'm not able to find it. Can anyone please help me with this? Thanks.
回答1:
The attribute textSize
works for me:
<item name="android:textSize">18sp</item>
来源:https://stackoverflow.com/questions/33260009/style-radio-button-and-text-inside-alertdialog