Stranger B.
Stranger B.

Reputation: 9364

How to have Material Design for Pre-Lollipop Devices

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" />

Upvotes: 0

Views: 364

Answers (2)

tk1505
tk1505

Reputation: 312

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

More info here

Upvotes: 1

PPartisan
PPartisan

Reputation: 8231

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

Upvotes: 3

Related Questions