增长了 Material Theming,新的组件、黑暗主题支持、等等android
新的功能:markdown
全部组件都支持黑暗主题app
新的日期选择器(具备范围选择功能和提高可访问功能)工具
扩展 Floating Action 按钮oop
切换按钮组测试
支持 Android 10 进行边缘手势导航的组件字体
改善无障碍功能google
全新的 Material Theming (形状、板式、颜色)spa
稳定性和质量改进设计
Material Components for Android(MDC)是从之前的 Design Support Library
库演变而来,是与 AndroidX
来搭配的。考虑到版本兼容和过渡,一开始的 1.0.0
版本与 design 库 28.0.0
是等价的。命名发生了改变从 com.android.support.design
到 com.google.android.material
。不事后续更新 design
库就再也不更新了,也就是说 design
库就永远的停留在了 1.0.0
这个版本了。
从 1.0.0
开始 Material Design
的规范不断发展。出现了新的规范、准则和新的组件,来更好的表明品牌同时保持了 Material
的核心原则。MDC
的目的是为开发者提供一个库,该库经过代码形式来实现这些组件和准则。随着指南不断的变化更新,MDC 将进行调整并更新来知足新的规范。
**MDC从 1.0.0
开始发生了大量的改变!**若是你还在使用测试版或者1.0.0
请尽快迁移到 1.1.0
版本或者更新版本。
Material Theming
可让你更好的自定义 Material Design
来体现咱们的品牌、颜色、字体和形状的选择。
MDC 1.1.0
在您的 Android 应用中启用 Material Theming
。全部组件都支持经过主题、样式、新属性和自定义类(好比:MaterialShapeDrawable
) 来调整其颜色、字体和形状。
// 这个地方要继承 Theme.MaterialComponents.*
<style name="Theme.MyApp" parent="Theme.MaterialComponents.*"> <!-- Color attributes --> <item name="colorPrimary">@color/green_500</item> <item name="colorPrimaryVariant">@color/green_700</item> <item name="colorOnPrimary">@color/black</item> <item name="colorSecondary">@color/orange_500</item> <item name="colorSecondaryVariant">@color/orange_300</item> <item name="colorOnSecondary">@color/black</item> <item name="colorError">@color/red_700</item> <item name="colorOnError">@color/white</item> <item name="colorSurface">@color/white</item> <item name="colorOnSurface">@color/black</item> <item name="android:colorBackground">@color/white</item> <item name="colorOnBackground">@color/black</item> <!-- Type attributes --> <item name="textAppearanceHeadline1"> @style/TextAppearance.MyApp.Headline1 </item> <item name="textAppearanceHeadline2"> @style/TextAppearance.MyApp.Headline2 </item> <item name="textAppearanceHeadline3"> @style/TextAppearance.MyApp.Headline3 </item> <item name="textAppearanceHeadline4"> @style/TextAppearance.MyApp.Headline4 </item> <item name="textAppearanceHeadline5"> @style/TextAppearance.MyApp.Headline5 </item> <item name="textAppearanceHeadline6"> @style/TextAppearance.MyApp.Headline6 </item> <item name="textAppearanceSubtitle1"> @style/TextAppearance.MyApp.Subtitle1 </item> <item name="textAppearanceSubtitle2"> @style/TextAppearance.MyApp.Subtitle2 </item> <item name="textAppearanceBody1"> @style/TextAppearance.MyApp.Body1 </item> <item name="textAppearanceBody2"> @style/TextAppearance.MyApp.Body2 </item> <item name="textAppearanceCaption"> @style/TextAppearance.MyApp.Caption </item> <item name="textAppearanceButton"> @style/TextAppearance.MyApp.Button </item> <item name="textAppearanceOverline"> @style/TextAppearance.MyApp.Overline </item> <!-- Shape attributes --> <item name="shapeAppearanceSmallComponent"> @style/ShapeAppearance.MyApp.SmallComponent </item> <item name="shapeAppearanceMediumComponent"> @style/ShapeAppearance.MyApp.MediumComponent </item> <item name="shapeAppearanceLargeComponent"> @style/ShapeAppearance.MyApp.LargeComponent </item> </style>
复制代码
Material Components
库中有不少新的组件添加到了 MDC 1.1.0
中。而且已经存在的组件也是经过最新的设计有了新的 style
若是您使用的是Design库
或者 MDC 1.0.0
那么组件将自动采用这些新样式。例如,文字有新的默认的 appearance
MDC 1.1.0
中提供的一些新组件和更新组件包括:
在 Android 10 中引入了系统范围的深色主题支持。连同 Material Design 指南。MDC 能够当即使用 Material Dark
主题。它以现有的 AppCompat DayNight
功能为基础,所以不用从头开始实现它:
DayNight
形式。这些会根据设备配置自动在 -night
和 -not-night
资源定位符之间切换。colorPrimary
colorSecondary
以使品牌在黑暗主题中的饱和度下降。默认状况下 colorSurface android:colorBackground
使用深灰而不是黑色来减轻眼睛疲劳,使高程度更明显,并确保与文本和其余元素造成适当的对比度。elevation
的数值。colorSurface
来替换了 colorPrimary
做为其背景色。这是由一个新的颜色属性 colorPrimarySurface
(更加当前的模式在 colorPrimary
和 colorSurface
之间切换)和组件的PrimarySurface
style 来提供支持。手势导航是在 Android10 中引入的。某些 MDC 组件经常处于主手势的区域(好比,BottomNavigationView
以及从底部向上滑动的原始手势)。相关组件已经更新,以考虑这些手势区域以及设备方向。适当的 padding/margin
值会自动被申请,用 WindowInsets
API(在 Android 10 或者更高版本)。
许多可 accessibility
改进已经加入到 MDC 组件中。这主要包含更好的 "话语提示" 在有用的内容描述、功能和各部分的排序。例如,TextInputLayout
如今按正确的顺序读取其提示,输入以及帮助程序或错误文本。
咱们已经收到了您关于 MDC 版本的反馈。咱们致力于更新而且整合您的重要贡献。