Android 设计支持库和 Material 设计向后兼容性?

Android Design Support Library And Material Design Backwards Compatibility?

我是新来的,请多多包涵! 我对新的设计支持库(以及如何实现支持库)有点困惑,我有两个问题:

非常感谢!

I'm confused about how support libraries are implemented. Is it something as simple as saying 'if the OS version is below version 5.0, use the V7 support library', or would I have to code an 'Alternative Layout'(One for devices running +5.0, and one for devices running older version of android?)

这些库会为您考虑其中包含的视图与 Lollipop 之前(和 M 之前)设备的兼容性。

Does the Design Support Library replace or add-to the V7 support libraries? (If I wanted to include, say, cards and a snack bar in an app, would I be able to just use the Design Support Library or would I have to use it along with the v7 cardview library? I know it's a stupid question, but I just want to make sure.)

添加到。设计支持库包含一些专用于帮助实现完美 "materialized" 应用程序的视图。对于 RecyclerView、CardView、Palette 等,您必须使用它们单独的支持库。例如:

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:design:22.2.0'

您可以使用 support libraries 将上一个 api(例如 21)引入的一些功能反向移植到旧设备 运行 上一个 api 级别。

例如,API21 引入了一个新的小部件,Toolbar。此小部件只能在 API >=21.

的设备上使用

借助 appcompat rel.21(一个 v7 支持库),您可以使用 Toolbar(注意软件包)在旧设备中实现您的工具栏 运行 API>=7.

这可能是因为支持库包含在您的 apk 中。

设计支持库是一个添加了新功能的新库。 它包含 Snackbar、TextInputLayout、FloatingActionButton 等视图,但不包含 Card。

因此将此依赖项用于设计支持库:

compile 'com.android.support:design:22.2.0'

此依赖关系使用 AppCompat 库

compile 'com.android.support:appcompat-v7:22.2.0'

官方 CardView 的这个依赖项

compile 'com.android.support:cardview-v7:22.2.0'

查看官方文档了解更多信息。