Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Change the color of Switch

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 7.20k
    Comment on it

    In android, switch is the toggle widget that has two states to select two options.

    User can simply click to toggle or drag back and forth to select the option.

    Here, I am changing the ON color of the SwitchCompat. SwitchCompat is the version of Switch provided in V7.

    I apply a custom theme to the SwitchCompat through theme property



    Below is the code:



      <style name="Theme.ToogleTheme" parent="Theme.AppCompat.Light">
            <!-- colorPrimary is used for the default action bar background -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <!-- colorPrimaryDark is used for the status bar -->
            <item name="colorPrimaryDark">@color/colorPrimary</item>
            <!-- colorAccent is used as the default value for colorControlActivated,
                 which is used to tint widgets -->
            <item name="colorAccent">@color/colorPrimary</item>
            <!-- You can also set colorControlNormal, colorControlActivated
                 colorControlHighlight, and colorSwitchThumbNormal. -->


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: