How to change the checkbox color of a Multiselectlistpreference

Asked

Viewed 1,486 times

1

I wonder if you can change the colors of those CheckBox which is currently green (standard color) for my accent color app.

Imagem

2 answers

0

You need to create a selector that way:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@drawable/checked" />
    <item android:state_checked="false" android:drawable="@drawable/unchecked" />
</selector>

Save it in the folder res/drawables/ by the name of cb_selector.xml

Then when it’s time to declare your checkbox, put it as a button, like this:

<CheckBox
    android:id="@+id/cb"
    android:text="My CheckBox"
    android:button="@drawable/cb_selector"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
  • I have no right access to Checkbox, I am using Multiselectlistpreference

0


You can customize through the style.xml, the result should be similar to this:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <!-- Add this -->

    <item name="android:dialogTheme">@style/DialogStyle</item>
    <item name="android:alertDialogTheme">@style/DialogStyle</item>

</style>

<!-- Personalize a cor aqui -->

<style name="DialogStyle" parent="android:Theme.Material.Dialog">
    <item name="android:colorAccent">@color/colorAccent</item>
</style>

Details

  • Great references! You helped me in a way that... My God! Thank you very much :D

  • @Iagosilva ... opa! Need only give a shout here"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.