Material Design系列

Android(Lollipop/5.0) Material Design(一) 简介

Android(Lollipop/5.0) Material Design(二) 入门指南

Android(Lollipop/5.0) Material Design(三) 使用Material主题

Android(Lollipop/5.0) Material Design(四) 创建列表和卡片

Android(Lollipop/5.0) Material Design(五) 定义阴影和裁剪View

Android(Lollipop/5.0) Material Design(六) 使用图片

Android(Lollipop/5.0) Material Design(七) 自定义动画

Android(Lollipop/5.0) Material Design(八) 保持兼容性


官网地址:https://developer.android.com/training/material/theme.html


新的Material主题提供了:

· 系统Widgets可设置它们的调色板

· 系统Widgets的触摸反馈动画

· Activity的过渡动画


您可以自定义Material主题,根据你的品牌标识,一个调色板来控制。

可以使用主题属性来为操作栏和状态栏着色,如图所示:



Material主题的定义:
@android:style/Theme.Material (dark version)
@android:style/Theme.Material.Light (light version)
@android:style/Theme.Material.Light.DarkActionBar

注:Material主题只能5.0(api21)及以上才能使用support-v7提供了兼容支持。详见保持兼容性

Customize the Color Palette 自定义调色板

自定义 基于颜色的适合你的品牌的主题,当继承了Material主题时,可以使用Material主题中的属性来自定义颜色

<resources> <!-- inherit from the material theme --> <style name="AppTheme" parent="android:Theme.Material">  <!-- Main theme colors -->  <!--  your app branding color for the app bar -->  <item name="android:colorPrimary">@color/primary</item>  <!--  darker variant for the status bar and contextual app bars -->  <item name="android:colorPrimaryDark">@color/primary_dark</item>  <!--  theme UI controls like checkboxes and text fields -->  <item name="android:colorAccent">@color/accent</item> </style></resources>

Customize the Status Bar 自定义状态栏

Material主题可以让你轻松地定制状态栏,所以您可以指定一个适合你品牌的颜色,并提供足够的对比度显示白色的状态图标,

当继承自Material主题时,设置状态栏时自定义颜色:android:statusBarColor。默认情况下,android:statusBarColor继承了android:colorPrimaryDark。

你可以自己绘制状态栏。例如,你想在照片上能明显的显示状态栏,用一个细微的黑色渐变来确保白色状态栏图标可见。为此,设置android:statusBarColor属性为@android:color/transparent,并根据需要调整Window的flags。对于动画或消退(fading),你也可以使用Window.setStatusBarColor()方法

当你自定义导航和状态栏时,要么使它们都透明,要么只修改状态栏。导航栏在其他所有情况下必须保持黑色。

Theme Individual Views 个人主题View

在layout的xml定义中,可以使用android:theme来指定该View所适用的主题,指定后,它将改变当前View及其子View的theme。


更多相关文章

  1. android自定义view属性
  2. Android编译过程详解(三)
  3. Android系统自带样式(@android:style/) (转)
  4. Android平台定义的主题样式
  5. Android2.2 自带主题themes.xml的源代码
  6. Android系统自带样式(@android:style/)
  7. Android系统自带样式(@android:style/)
  8. android中系统自带主题集锦
  9. Android系统自带样式(@android:style/)

随机推荐

  1. android 日常迭代与维护总结二
  2. Android圆角图片最佳方案
  3. RePlugin阅读源码环境搭建
  4. android boot 代码流程
  5. Android Monkey测试脚本
  6. Android开发中的logcat工具使用
  7. 五.在Android中实现线程的方法
  8. android:contentDescription的作用是什么
  9. Android:activity context, application
  10. Android和Html的简单交互