Material Theme


Material Theme提供了一下功能:

1、系统widgets可以设置调色板

2、系统widgets的触摸反馈

3、Activity过渡动画


    你可以根据你品牌的色彩来定义Material Theme,可以使用Material Theme的色彩为status bar、action bar着色。参考下图。



系统Widgets有新的设计和触摸动画,你也可以在自己的应用中自定义色彩调色板、触摸反馈动画、Activity过渡。


Material Theme的定义如下:

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

你可以使用一系列的material styles,查看 android.R.style 参考。


Customize the Color Palette

    自定义主题的基础颜色以适应你品牌,使用Theme属性自定义颜色,Theme继承自Material Theme。

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
    <!-- Main theme colors -->
    <!--   your app's branding color (for the app bar) -->
    <item name="android:colorPrimary">@color/primary</item>
    <!--   darker variant of colorPrimary (for status bar, 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 and Navigation Bar


    使用material theme可以简单的自己定制status bar,可以让status bar适应你的产品,这个在iOS中也是可以实现的。可以设置android:statusBarColor属性来设置status bar的颜色。前面看到的

android:colorPrimaryDark

会默认设置为status bar的颜色。

    java方法中可以使用Window.setStatusBarColor方法改变status bar来改变色彩。

Theme Individual Views


XML布局中定义元素可以指定android主题属性。就是可以为你的views在Theme中声明各种属性的值。


这一点,说的最主要的是可以改变status bar的颜色,以前的版本是不可以的。

/**
* @author 张兴业
*  我的新浪微博:@张兴业TBOW
*/

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值