Appcompact DialogFragment single-choice checkmark color
Asked Answered
N

3

6

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) ???enter image description here

Nestle answered 3/3, 2015 at 19:49 Comment(0)
A
7

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();
}
Assiniboine answered 20/8, 2015 at 22:22 Comment(0)
W
1

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

Wartow answered 4/3, 2015 at 5:49 Comment(1)
No problem. If you get stuck let me knowWartow
S
1

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) {
                    //.. 

            });
Steading answered 26/10, 2016 at 23:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.