It is impossible to alter the accent color for a particular switch.

<Switch android:id="@+id/switch1" style="@style/exesSwitch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|right" android:layout_weight="80" android:checked="true" /> 

On one of the forums I found this solution, but somehow it did not help me.

 <style name="exesSwitch" parent="Theme.AppCompat.Light"> <!-- active thumb & track color (30% transparency) --> <item name="colorControlActivated">#46bdbf</item> <!-- inactive thumb color --> <item name="colorSwitchThumbNormal">#f1f1f1 </item> <!-- inactive track color (30% transparency) --> <item name="android:colorForeground">#42221f1f</item> </style> 

I also tried to create a style with a single parameter:

 <item name="colorAccent">@color/colorPAccent</item> 

For all switch attempts, everything also uses the primary colorAccent.

    1 answer 1

    The problem was that the style was not properly connected. The previous version worked in api <20 It was necessary like this

     <android.support.v7.widget.SwitchCompat android:id="@+id/switch1" android:theme="@style/exesSwitch" ...