Material Design

2021-05-17  本文已影响0人  lq_ios

如何在项目中引入Material Design

将下面这段代码加入项目或者模块的build.gradle的文件中,具体的版本号可以在 它的GitHub仓库地址上找到

implementation "com.google.android.material:material: 版本号" 

Material Design 包含的组件

文档

组件名 文档地址 简介
App bars: bottom https://material.io/components/app-bars-bottom 位于APP底部的导航,可以和FloatingActionButton搭配使用
App bars: top https://material.io/components/app-bars-top 位于APP顶部的导航
Backdrop https://material.io/components/backdrop#bottom-app-bar 背景由两个layer组成:back layer 和 front layer.。底层显示动作和上下文,这些动作和上下文控制并通知顶层的内容
Banners https://material.io/components/banners 标语显示突出的消息和相关的可选操作。
Bottom navigation https://material.io/components/bottom-navigation 底部导航栏,类似于iOS的TabBar
Buttons https://material.io/components/buttons 按钮
Buttons: floating action button https://material.io/components/buttons-floating-action-button 悬浮按钮
Cards https://material.io/components/cards 卡片包含有关单个主题的内容和动作。
Checkboxes https://material.io/components/checkboxes 复选框
Chips https://material.io/components/chips 用于表示输入
Data tables https://material.io/components/data-tables 表格
Date pickers https://material.io/components/date-pickers 时间选择器
Dialogs https://material.io/components/dialogs 对话框
Dividers https://material.io/components/dividers 分割线
Image lists https://material.io/components/image-lists 图片列表
Lists https://material.io/components/lists 列表
Menus https://material.io/components/menus 菜单
Navigation drawer https://material.io/components/navigation-drawer 侧边抽屉
Navigation rail https://material.io/components/navigation-rail 导航栏可在应用程序的主要目的地之间提供符合人体工程学的移动
Progress indicators https://material.io/components/progress-indicators 进度条
Radio buttons https://material.io/components/radio-buttons 单选框
Sheets: bottom https://material.io/components/sheets-bottom 底部弹出窗口
Sheets: side https://material.io/components/sheets-side 侧边栏
Sliders https://material.io/components/sliders 拖拽进度条
Snackbars https://material.io/components/snackbars 底部弹出可带有按钮的Toast
Switches https://material.io/components/switches 开关
Tabs https://material.io/components/tabs 可以和VIewPage配合使用的导航
Text fields https://material.io/components/text-fields 输入框
Time pickers https://material.io/components/time-pickers#usage 时间选择器
Tooltips https://material.io/components/tooltips#usage 当用户将鼠标悬停,聚焦或点击某个元素时,工具提示将显示信息丰富的文本。

全局的主题属性

Color属性

属性名 描述
colorPrimary APP的主要颜色,actionBar默认使用该颜色,Toolbar导航栏的底色
colorPrimaryVariant APP的主要颜色的较浅/较暗变体,在主题中很少使用
colorOnPrimary 用于显示在原色上方的元素的颜色(例如,文本和图标,根据可访问性,通常为白色或半透明的黑色)
colorSecondary APP的次要色彩,主要用于强调某些需要突出的小部件
colorSecondaryVariant APP的次要色彩的较浅/较深变体,在主题中很少使用
colorOnSecondary 用于显示在辅助颜色顶部的元素的颜色
colorError 用于错误的颜色(通常为红色阴影)
colorOnError 用于显示在错误颜色顶部的元素的颜色
colorSurface 用于表面的颜色
colorOnSurface 用于显示在表面颜色顶部的元素的颜色
android:colorBackground 所有其他屏幕内容后面的颜色
colorOnBackground 用于显示在背景色上方的元素的颜色
colorPrimaryDark APP的主要暗色调,statusBarColor默认使用该颜色
statusBarColor 状态栏颜色,默认使用colorPrimaryDark
windowBackground 窗口背景颜色
navigationBarColor 底部栏颜色
colorForeground 应用的前景色,ListView的分割线,switch滑动区默认使用该颜色
colorAccent CheckBox,RadioButton,SwitchCompat等一般控件的选中效果默认采用该颜色
colorControlNormal CheckBox,RadioButton,SwitchCompat等默认状态的颜色
colorControlHighlight 控件按压时的色调
colorControlActivated 控件选中时的颜色,默认使用colorAccent
colorButtonNormal 默认按钮的背景颜色
editTextColor 默认EditView输入框字体的颜色。
textColor Button,textView的文字颜色
textColorPrimaryDisableOnly RadioButton checkbox等控件的文字
textColorPrimary 应用的主要文字颜色,actionBar的标题文字默认使用该颜色
colorSwitchThumbNormal switch thumbs 默认状态的颜色. (switch off)

Type 属性

Type 属性在文字字体重量大小大小写字母间距方面都符合Material Type System。这些属性引用实现(并以其命名)各种类型比例的样式:TextAppearance.MaterialComponents.

属性名 描述
textAppearanceHeadline1 轻,96sp
textAppearanceHeadline2 轻,60sp
textAppearanceHeadline3 常规的48sp
textAppearanceHeadline4 常规的34sp
textAppearanceHeadline5 常规,24sp
textAppearanceHeadline6 中20sp
textAppearanceSubtitle1 常规16sp
textAppearanceSubtitle2 中14sp
textAppearanceBody1 常规16sp
textAppearanceBody2 常规,14sp
textAppearanceButton 常规,14sp,全大写
textAppearanceOverline 常规,12sp,全大写
上一篇 下一篇

猜你喜欢

热点阅读