In order to ensure your application with other applications installed on the user device consistent visual and behavior, we recommend you follow Material Design specifications , because users learn from one application mode of operation may be in another seamless Used in an application.
Android users expect your app to be visually and behaviorally consistent with the system. You should follow the Material Design specification when designing the visual and navigation modes...
You can use Material Design Components (MDC) component library to achieve the purpose of This article will list the advantages of using MDC and explain why we recommend it.
component
MDC provides the Material version of the system standard components, such as Buttons , Toolbars , CheckBox etc., using these components can easily realize the Material style. If you use the MaterialComponents theme, when you inflate a layout ( View Inflater through MDC), it is instantiated as a Material component instead of a standard component, so you can easily implement the Material style without major updates to the layout .
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- 标准组件 Button 将会被替换为 MaterialButton -->
<Button ... />
<!-- 您甚至可以使用 MaterialButton 特定的属性 -->
<Button ...
app:icon="@drawable/foo"/>
<!--如果您想用具有向后兼容能力的 AppCompatButton 而不是 MaterialButton,您可以这样做 -->
<androidx.appcompat.widget.AppCompatButton ... />
All Material components inherit from the corresponding AppCompat components, so they enjoy the same backward compatibility and bug fixes in the new version.
The Material component expands more styles and functions on the basis of the corresponding system standard components and AppCompat components. For example, MaterialButton has the following styles:
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<!-- Contained button -->
<Button ...
style="?attr/materialButtonStyle"/>
<!-- Text button -->
<Button ...
style="?attr/borderlessButtonStyle"/>
<!-- Outlined button -->
<Button ...
style="?attr/materialButtonOutlinedStyle"/>
One of my favorite features is the use of MaterialTextView replace TextView, it new features can be easily set up in TextAppearance high line.
In addition to expanding the functions of existing components, MDC also provides a series of brand new components. You may know Bottom Navigation , Bottom Sheet and Floating Action the Button , but may not have heard of Chips , a Date Picker and Time Picker .
For a list of all components provided by MDC, please refer to- components .
Material theme
Material theme can be more systematic custom Material Design style to reflect your brand. Material theme includes color , font style and shape attributes. Customizing it will automatically apply to the components you use to build your application.
You can understand the Material theme as a design system for creating a design system🤯. You only need to configure the colors, font styles and shapes to get a complete design system based on your brand.
Nick Rout describes these three subsystems in depth in the following articles:
- Create Material Color Theme | Implementation
- to create a Material font style theme | Implementation
- Create Material Shape Theme | Implementation Chapter
Dark theme
The MDC component implements the dark theme dark theme background specification Under the dark theme, many components will adjust their colors, and an elevation overlay is added to express height changes when the shadows are not visible.
Chris Banes provides an in-depth introduction to the dark theme of MDC in the following article:
Material Motion Effect🆕
Material Design has also formulated specifications for transition animations. Now, MDC not only provides the specification , but also implements these modes as Transitions so that you can use them in your applications.
Hunter Stich introduces the Material Motion library in the following article:
using Compose
Jetpack Compose is the next generation UI toolkit for Android system. At present, has officially released . It will provide Material style components and themes. Early use of MDC will prepare you for future migration to Jetpack Compose—they use the same concepts, design terms, and components. You can even use a like 16117942a6103a MDC-Android Compose Theme Adapter to simplify the migration process, which converts the XML-implemented MDC theme to Compose’s MaterialTheme .
Recommended to use Material
Hope you have already understood why we recommend Material Design Components build Android UI. Our recently updated to create new templates in Android Studio through the File> New Project menu. These templates pre-set Material themes for you and use MDC, so you can start using MDC more easily. If you have not yet migrated to MDC, please check our migration guide .
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。