- 原文地址:Android Getting Started with Material Design
- Material Design 在Android Lollipop版本(Android 5.0)被引进
- Material Design 带来了一些新的主题,特性和控件和动画,比如:Material Theme*, new widgets, custom shadows, vector drawables and custom animations.
-
使用Material Design的一般步骤如下:
- 下载安装Android开发环境:Android Studio
- 新建一个Android的项目
- 在res/values文件下的strings文件中添加业务相关的string,注意string的国际化
- 在 res ⇒ values ⇒ colors.xml 自定义Material Design 的颜色主题资源,
<code>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#F50057</color>
<color name="colorPrimaryDark">#C51162</color>
<color name="textColorPrimary">#FFFFFF</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#FF80AB</color>
</resources>
</code> - 在res/values文件下的dimens.xml添加尺寸
- 在res/values文件下的styles.xml自定义styles,代码如下:
接下来最重要的一步,在AndroidManifest.xml清单文件中使用我们定义好的主题:
<code>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyMaterialTheme" >
...
...
</application>
</code>然后编译运行程序会看见我们设计的Material Design的效果:
-
项目的组织结构
上面是为APP设置Material Design的基本效果
- 一般Material Design 会配合Toolbar,DrawerLayout,Navigation View,Floating Tables ,Fragment,Floating Action Button ,Snackbar,RecyclerView等控件配合使用
拓展学习
What’s Next?
Below are few more material components you can add to your app. These were implemented using recent Android Design Support Library.
- Material Design Tab Layout
If you want to add tabs to your app, Android Material Design Tabs covers different aspects of Tab Layout. - Floating Labels for EditText
Learn how floating labels works on EditText with a simple form validation example. - Floating Action Button (FAB)
Add the Floating Action Button to your which displays in circular shape floating on the top of the UI. - Snackbar
Add the Snackbar to your app to give immediate feedback about any operation that user performed.