dimanche 28 mai 2017

Change the multiple choice list item checkbox tint

I have a list view with choice mode set to multiple. I have set the layout to simple_list_item_multiple_choice. It gives the checkboxes in the right side of the row.

But here's the problem: button tint of these checkboxes is terrible blue (which is far from my application color scheme). Whatever I do, I can't change it. I have already tried: creating a style for CheckBox and creating a style for CheckedTextView, changing there all kinds of button tints and color accents. None of it works. What should I do?

A piece of layout:

...
   <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/listView1"
    android:layout_weight="1"
    android:choiceMode="singleChoice" /> ...

A piece of activity code:

  ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),
  android.R.layout.simple_list_item_multiple_choice, players);
  itemsList.setAdapter(adapter);

Solutions I've tried:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:colorPrimary">@color/MainColor</item>
    <item name="android:colorAccent">@color/colorAccent</item>
    <item name="android:textColor">@color/MainColor</item>
    <item name="colorAccent">@color/MainColor</item>
    <item name="colorPrimary">@color/MainColor</item>
    <item name="android:checkboxStyle">@style/CheckBoxStyle</item>
    <item name="android:checkedTextViewStyle">@style/CheckedTextViewStyle</item>
</style>
<style name="CheckBoxStyle" parent="AppTheme">
    <item name="android:tint">@color/colorAccent</item>
    <item name="android:buttonTint">@color/colorAccent</item>
</style>

<style name="CheckedTextViewStyle" parent="AppTheme">
    <item name="android:colorButtonNormal">@color/colorAccent</item>
    <item name="android:checkMarkTint">@color/colorAccent</item>
    <item name="android:tint">@color/colorAccent</item>
    <item name="android:buttonTint">@color/colorAccent</item>
    <item name="android:colorAccent">@color/colorAccent</item>
</style>




Aucun commentaire:

Enregistrer un commentaire