Cambiar colorControlActivated color programmically

He leído algunos temas sobre el color, pero todos ellos tienen que establecer a través de style.xml.

Por ahora estoy usando esto para determinar el color.

<style name="Color1SwitchStyle"> <item name="colorControlActivated">#0e8488</item> </style>' 

¿Es posible cambiar el color de un SwitchCompat / Checkbox sin utilizar XML, por ejemplo, utilizando código?

En realidad, no es difícil de hacer.

Ejemplo:

 int[][] states = new int[][] { new int[] {-android.R.attr.state_checked}, new int[] {android.R.attr.state_checked}, }; int[] thumbColors = new int[] { Color.BLACK, Color.RED, }; int[] trackColors = new int[] { Color.GREEN, Color.BLUE, }; SwitchCompat switchCompat = (SwitchCompat) findViewById(R.id.switchControl); AppCompatCheckBox checkBox = (AppCompatCheckBox) findViewById(R.id.checkbox); checkBox.setSupportButtonTintList(new ColorStateList(states, thumbColors)); DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getThumbDrawable()), new ColorStateList(states, thumbColors)); DrawableCompat.setTintList(DrawableCompat.wrap(switchCompat.getTrackDrawable()), new ColorStateList(states, trackColors)); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.