difference between switch and switchcompat in android?
Asked Answered
P

1

0

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

Pantelegraph answered 9/11, 2015 at 7:19 Comment(4)
@beardedbeast: I think only diff is Switch is added from API LEVEL 14 but SwitchCompat is used to support Switch control till API LEVEL 7Tout
ya thats what I saw in the referencePantelegraph
Then you have your answer.Sosanna
is that the only difference ?Pantelegraph
E
1

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.

Erective answered 9/11, 2015 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.