Can someone please explain the real difference between Switch
and SwitchCompat
.Can I use both as toggle button. can both support lower versions of android. thanks in advance
As beardedbeast already mentioned in comment, these widgets differ from each other only by the supported API level. You can use both of them for the same purpose but not simultaneously to avoid unnecessary complication.
As for known issues when using Compat widgets, there is an answer from developers.blogspot:
You don’t need to do anything special to make these work, just use these controls in your layouts as usual and AppCompat will do the rest (with some caveats; see the FAQ below).
And one points, which is not mentioned there. To have correct look and behavior of SwitchCompat
(and other Compat widgets) check if the parent Activity
(or LayoutInflater
which you are using to inflate Compat view) is styled with Theme.AppCompat
.
© 2022 - 2024 — McMap. All rights reserved.
Switch
is added from API LEVEL 14 butSwitchCompat
is used to supportSwitch
control till API LEVEL 7 – Tout