Change window color of Android CheckBox programmatically (library support)?

I am trying to change the color of a checkbox window programmatically to a different color than the default theme. The problem is that I was doing something like this:

checkbox.setSupportButtonTintList(ColorStateList); 

This works, but it seems that according to its class documentation, this method was limited to be used only by classes from a single package (com.android.support). This is the warning I received from Android Studio:

 AppCompatCheckBox.setSupportButtonTintList can only be called from within the same library group (groupId=com.android.support) 

Is there a standard / correct way to do this for all API levels?

+5
source share
1 answer

Finally, I found the answer here from one of the Google guys: https://code.google.com/p/android/issues/detail?id=202235 . I was right about not using:

 checkbox.setSupportButtonTintList(ColorStateList); 

This seems to be a private API. Instead, you should use:

 CompoundButtonCompat.setButtonTintList(checkbox, colorStateList); 
+12
source

Source: https://habr.com/ru/post/1263076/


All Articles