difference between switch and switchcompat in android?

丶灬走出姿态 提交于 2020-01-07 03:04:10

问题


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


回答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.



来源:https://stackoverflow.com/questions/33604164/difference-between-switch-and-switchcompat-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!