简体   繁体   English

Android 中的 Theme.AppCompat 和 Theme.Material 有什么区别?

[英]What is the difference between Theme.AppCompat and Theme.Material in Android?

In My case, what is difference in here:就我而言,这里有什么区别:

<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">

and

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

This is the raw material design theme, which is used by Android 5 and up Not sure how this works wrt.这是原始材料设计主题,由 Android 5 及更高版本使用不知道这是如何工作的。 new Android libraries for app design :用于应用程序设计的新 Android 库

<style name="AppTheme" parent="android:Theme.*">

This is a way to use material design on pre-lollipop devices, which maintains compatibility.这是在 pre-lollipop 设备上使用材料设计的一种方式,它保持兼容性。

<style name="AppTheme" parent="Theme.AppCompat.*">

You can design for newer APIs using AppCompat and still have it work on earlier API levels than what the base level for material design is.您可以使用 AppCompat 设计更新的 API,并且仍然可以在比 Material Design 的基础级别更早的 API 级别上工作。

In this case, it essentially means that you can run material design on platforms that predate material design.在这种情况下,它本质上意味着您可以在早于材料设计的平台上运行材料设计。 This isn't as important anymore now that versions that early make up at most ~2.5% of the market share at the time of writing.在撰写本文时,早期版本最多占市场份额的约 2.5%,因此这不再那么重要了

Note, however, that using AppCompat does give you additional compatibility helpers beyond just being able to use the material theme on older devices.但是请注意,使用 AppCompat 确实为您提供了额外的兼容性帮助程序,而不仅仅是能够在旧设备上使用材料主题。 Also note that AppCompat has since been deprecated in favor of whatever system is currently mainstream and that Google hasn't axed yet (Jetpack?), which may or may not work differently.另请注意,AppCompat 已被弃用,取而代之的是当前主流的任何系统,而且 Google 尚未砍掉(Jetpack?),这可能会或可能不会以不同的方式工作。

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">    
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">

Theme.AppCompat is for above API 7+ Theme.AppCompat 适用于API 7+ 以上

Theme.Material is for above API 21+ Theme.Material 适用于API 21+ 以上

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

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