I want to have the Lollipop style switch button for my app:
How could I implement this button so it looks like this also on older versions of android?
I want to have the Lollipop style switch button for my app:
How could I implement this button so it looks like this also on older versions of android?
To have the Lollipop style switch button on older versions of android you should use SwitchCompat in layout xml file
and also in java file
API 24 on off switch
In order to resolve old type switch
switch_old
`
and it resolve switch with latest material design.
There is a great article on the Android Developers Blog that discusses how to use material design on pre-Lollipop devices: http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
To more specifically answer your question, you can use the Lollipop style switch for older versions by using the
SwitchCompat
API: https://developer.android.com/reference/android/support/v7/widget/SwitchCompat.htmlAt first set
android:targetSdkVersion="22"
in your manifest to make your app compatible to Lollipop.NOTE: Color of your switch depends on this
Create your own theme for your app in styles.xml in Folder values-v21
styles.xml in default Folder values or values-v14
I think what you need is in that library
what this library does is to allow you to create material design switch button like in andorid 5.0
https://github.com/kyleduo/SwitchButton