I have a problem. My activity has style
<style name="MaterialTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/action_bar_background</item>
<item name="colorPrimaryDark">@color/action_bar_background</item>
<item name="colorAccent">@color/action_bar_background</item>
</style>
also i have dialogFragment with simple single-choice chooser.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
dialog.setTitle(R.string.image_resolution);
dialog.setSingleChoiceItems(R.array.quality_labels, getPosition(), this);
return dialog.create();
}
How to change color of picker checkmarks (green circles) ???
You must create corresponding style for AlertDialog
<style name="MaterialThemeDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/action_bar_background</item>
</style>
and pass it to AlertDialog.Builder
constructor
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(
getActivity(),
R.style.MaterialThemeDialog);
dialog.setTitle(R.string.image_resolution);
dialog.setSingleChoiceItems(R.array.quality_labels, getPosition(), this);
return dialog.create();
}
You can reference a custom radio button through the ListAdapter
argument in AlertDialog.Builder.setSingleChoiceItems(ListAdapter, int, OnClickListener)
.
The answer in this SO post nails the details: Android Alert Dialog replace default blue with another color
For help with creating your custom components check out: http://android-holo-colors.com
1) Create a new xml, where checkMark is the style and animation of the checkmark, and the checkMarkTint is the color of the checkmark
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:paddingEnd="16dip"
android:layout_marginTop="10dp"
android:paddingStart="16dip"
android:textSize="14sp"
android:checkMark=""="?android:attr/listChoiceIndicatorSingle"
android:checkMarkTint="@color/your_checkmark_color"
android:textColor="@color/your_text_color" />
2) Then create an adapter above your alerDialog.SetSingleChoiceItems
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getApplicationContext(),R.layout.your_custom_layout, charSequenceList);
3) Add the adapter
alerDialog.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//..
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With