博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Material Design系列第三篇——Using the Material Theme
阅读量:6076 次
发布时间:2019-06-20

本文共 3147 字,大约阅读时间需要 10 分钟。

Using the Material Theme

This lesson teaches you to

You should also read

The new material theme provides:

  • System widgets that let you set their color palette
  • Touch feedback animations for the system widgets
  • Activity transition animations

You can customize the look of the material theme according to your brand identity with a color palette you control. You can tint the action bar and the status bar using theme attributes, as shown in .

The system widgets have a new design and touch feedback animations. You can customize the color palette, the touch feedback animations, and the activity transitions for your app.

The material theme is defined as:

  • @android:style/Theme.Material (dark version)
  • @android:style/Theme.Material.Light (light version)
  • @android:style/Theme.Material.Light.DarkActionBar

For a list of material styles that you can use, see the API reference for .

Figure 1. Dark material theme

Figure 2. Light material theme


Note: The material theme is only available in Android 5.0 (API level 21) and above. The provide themes with material design styles for some widgets and support for customizing the color palette. For more information, see .

Customize the Color Palette


To customize the theme's base colors to fit your brand, define your custom colors using theme attributes when you inherit from the material theme:

 
 
   
   
   
@color/primary
   
   
@color/primary_dark
   
   
@color/accent
 

Figure 3. Customizing the material theme.

Customize the Status Bar


The material theme lets you easily customize the status bar, so you can specify a color that fits your brand and provides enough contrast to show the white status icons. To set a custom color for the status bar, use the android:statusBarColor attribute when you extend the material theme. By default, android:statusBarColor inherits the value of android:colorPrimaryDark.

You can also draw behind the status bar yourself. For example, if you want to show the status bar transparently over a photo, with a subtle dark gradient to ensure the white status icons are visible. To do so, set the android:statusBarColor attribute to @android:color/transparent and adjust the window flags as required. You can also use the method for animations or fading.

Note: The status bar should almost always have a clear delineation from the primary toolbar, except for cases where you show edge-to-edge rich imagery or media content behind these bars and when you use a gradient to ensure that the icons are still visible.

When you customize the navigation and status bars, either make them both transparent or modify only the status bar. The navigation bar should remain black in all other cases.

Theme Individual Views


Elements in XML layout definitions can specify the android:theme attribute, which references a theme resource. This attribute modifies the theme for the element and any child elements, which is useful for altering theme color palettes in a specific portion of an interface.

转载地址:http://wfxgx.baihongyu.com/

你可能感兴趣的文章
Python简单爬虫入门二
查看>>
不关闭seLinux解决vsftpd服务本地用户不能登录问题(500 OOPS: cannot change directory:/home/***)...
查看>>
【第一阶段】第二周作业
查看>>
将多个Excel文件合并成一个excel文件
查看>>
项目Beta冲刺
查看>>
Unity与安卓IOS交互
查看>>
oracle dba比较好的书籍
查看>>
在MyEclipse中debug使用手册
查看>>
怎么让研发做好他们不重视但是对测试很重要的事情? 致
查看>>
UVa - 12096 The SetStack Computer(STL容器综合,强推!)
查看>>
斐波那契数列规律的解释及实现
查看>>
Mono ASP.NET core 添加 Entity Framework
查看>>
iOS 什么是函数式编程
查看>>
安卓 碎片 如何实现类似 活动 栈的 进栈 出栈
查看>>
参数请求post, get , delete中的基本使用(2)
查看>>
【封装】二叉树相关算法的实验验证
查看>>
3/31下午
查看>>
linux GTK 安装
查看>>
111
查看>>
关于Expression Tree和IL Emit的所谓的"性能差别&quot“.NET研究”;
查看>>