<二>Material主题的使用

http://developer.android.com/training/material/theme.html

Material主题带来的效果体现在以下几个方面:

  • System widgets that let you set their color palette(调色板)
  • 系统控件(部件)的触屏反馈动画
  • Activity跳转动画
当然,我们可以在app中对 color palette、 触屏反馈动画和 Activity跳转动画进行自定义。  

系统提供的主题样式:

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


Note:  这些M aterial主题效果只支持在   Android 5.0 (API level 21)的设备上使用 . 兼容包 v7 appcompat library(兼容5.0以下的设备) 只支持部分的样式和控件效果,详情:   Maintaining Compatibility .

自定义Color Palette


<resources>
  <!-- 继承自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>


colorPrimaryDark - 这是app中最黑的基本色,主要用来做notification bar的背景.

colorPrimary - 这是app的基本颜色,将用作toolbar的背景色

textColorPrimary - 文本颜色,用于toolbar的标题

windowBackground - app默认的背景颜色

navigationBarColor - 这个颜色定义了navigation bar页脚的背景色.


自定义状态栏

 
 使用属性 android:statusBarColor
 用法:
<resources>
  <!-- 继承自material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   ... -->
    <item name="android:statusBarColor">自定义颜色值</item>
    <!--  ... -->
  </style>
</resources>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值