0

I'm looking to have the same design for Pre-Lollipop devices.

In my application I'm using a switch button which is looking like this on Lollipop devices :

enter image description here

and on Pre-Lollipop devices. it's looking like this :

enter image description here

So how can I do that I have two styles folders :

enter image description here

my Styles xml looks like :

<resources>

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">

</style>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="actionModeBackground">@color/colorPrimaryDark</item>
</style>
<style name="MyMaterialTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="MyMaterialTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
Stranger B.
  • 9,004
  • 21
  • 71
  • 108

2 Answers2

3

You could use the SwitchCompat class instead of Switch to provide backwards compatibility.

PPartisan
  • 8,173
  • 4
  • 29
  • 48
1

For switch you need to use the new android.support.v7.widget.SwitchCompat

More info here

tk1505
  • 312
  • 1
  • 9