简体   繁体   English

Android设计支持库和材料设计向后兼容吗?

[英]Android Design Support Library And Material Design Backwards Compatibility?

I'm new here, so bear with me! 我是新来的,所以请忍受! I'm sorta confused about the new Design Support Library (and how one implements support libraries), and I had a two questions: 我对新的设计支持库(以及如何实现支持库)感到困惑,我有两个问题:

  • 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?) 是说“如果操作系统版本低于5.0,使用V7支持库”这样简单的话,还是我必须编写“替代布局” (对于运行+5.0的设备,对运行较旧版本的设备,一种)的Android吗?)
  • Does the Design Support Library replace or add-to the V7 support libraries? 设计支持库是否替代添加了V7支持库? (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.) (如果我想在应用程序中包含卡片和小吃店,我是否只能使用设计支持库,还是必须将其与v7 cardview库一起使用?我知道这是一个愚蠢的问题,但我只是想确保。)

Thanks a lot! 非常感谢!

You can use the support libraries to backport some features introduced with the last api (for example 21) to old devices running a previous api level. 您可以使用支持库将最后一个api(例如21)引入的某些功能移植到运行以前api级别的旧设备。

For example, API21 introduced a new widget, the Toolbar . 例如,API21引入了一个新的小部件Toolbar This widget can be used only in device with API >=21. 该窗口小部件只能在API> = 21的设备中使用。

With the appcompat rel.21 (a v7 Support library) you can use the Toolbar (pay attention to the package) to implement your Toolbar in old devices running API>=7. 借助appcompat rel.21(v7支持库),您可以使用工具栏 (请注意软件包)在运行API> = 7的旧设备中实现工具栏。

This can happen because the support libraries are included in your apk. 这是因为支持库包含在您的apk中。

The Design Support Library is a new library which add new features. 设计支持库是一个添加了新功能的新库。 It contains views as Snackbar, TextInputLayout, FloatingActionButton, but it doesn't contain the Card. 它包含诸如Snackbar,TextInputLayout,FloatingActionButton的视图,但不包含Card。

So use this dependency for the design support library: 因此,请将此依赖性用于设计支持库:

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

This dependency to use the AppCompat library 使用AppCompat库的这种依赖性

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

This dependency for the official CardView 官方CardView的这种依赖性

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

Check the official doc for more info. 查看官方文档以获取更多信息。

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?) 是说“如果操作系统版本低于5.0,使用V7支持库”这样简单的话,还是我必须编写“替代布局”的代码(一个用于运行+5.0的设备,一个用于运行较旧版本的设备)的Android吗?)

The libraries takes care for you of compatibility for pre-Lollipop (and pre-M) devices for the views contained in it. 这些库会照顾您与棒棒糖之前(和M之前)设备所包含视图的兼容性。

Does the Design Support Library replace or add-to the V7 support libraries? 设计支持库是否替代或添加了V7支持库? (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.) (如果我想在应用程序中包含卡片和小吃店,我是否只能使用设计支持库,还是必须将其与v7 cardview库一起使用?我知道这是一个愚蠢的问题,但我只是想确保。)

Add-to. 添加。 The design support library contains some views exclusive for helping to achieve a perfect "materialized" app. 设计支持库包含一些视图,这些视图专用于帮助实现完美的“物化”应用程序。 For RecyclerView, CardView, Palette etc, you must use their separate support libraries. 对于RecyclerView,CardView,Palette等,您必须使用它们各自的支持库。 Eg: 例如:

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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM