创建Material Design风格的Android应用--应用主题
来源:互联网 发布:java下载 编辑:程序博客网 时间:2024/05/01 11:08
昨天正式发布了android 5,同时android developer网站也更新了,增加了创建Material Design风格的Android应用指南,也更新了Support Library,在support library增加了一些Material Design风格的控件和动画等,这里给大家简单介绍一下怎样开发material design风格的Android应用。
android 5使用Material Design风格
android 5使用Material Design风格
android提供了三种Material Design风格Theme。
分别是:
@android:style/Theme.Material (dark version) @android:style/Theme.Material.Light (light version) @android:style/Theme.Material.Light.DarkActionBar
Light material theme
Dark material theme
我们可以以这三个Theme来定义我们的Theme,比如:
123456789101112
<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>
我们可以修改每个位置的字或者背景的颜色,每个位置的名字如下图所示:
我就简单的介绍一下,更具体的自己探索吧。
较低版本使用Material Design风格
要在较低版本上面使用Material Design风格,则需要使用最新的support library(version 21),可以直接把项目引入工程,或者使用gradle构建,增加compile dependency:
12345
dependencies {compile 'com.android.support:appcompat-v7:+'compile 'com.android.support:cardview-v7:+'compile 'com.android.support:recyclerview-v7:+'}
将上面的AppTheme style放到res/values-v21/style.xml,再res/values/style.xml增加一个AppTheme,如下:
1234567
<!-- extend one of the Theme.AppCompat themes --><style name="Theme.MyTheme" parent="Theme.AppCompat.Light"><!-- customize the color palette --><item name="colorPrimary">@color/material_blue_500</item><item name="colorPrimaryDark">@color/material_blue_700</item><item name="colorAccent">@color/material_green_A200</item></style>
这样可以同样实现很多的地方是Material Design,但是由于低版本不支持沉浸式状态栏,有一些效果还是无法实现。
参考:http://developer.android.com/training/material/theme.html
0 0
- 创建Material Design风格的Android应用--应用主题
- 创建Material Design风格的Android应用--应用主题
- 创建Material Design风格的Android应用--应用主题
- 创建Material Design风格的Android应用--应用主题
- 创建Material Design风格的Android应用--应用主题
- 创建Android Material Design的应用主题风格
- 创建Material Design风格的Android应用--应用主题(转)
- 创建Material Design风格的Android应用--使用Drawable
- 创建Material Design风格的Android应用--使用自定义动画
- 创建Material Design风格的Android应用--使用自定义动画
- 创建Material Design风格的Android应用--使用Drawable
- 创建Material Design风格的Android应用--使用自定义动画
- 创建Material Design风格的Android应用--使用自定义动画
- 创建Material Design风格的Android应用--使用自定义动画
- 创建Material Design风格的Android应用--创建列表和卡片
- 创建Material Design风格的Android应用--创建列表和卡片
- 创建Material Design风格的Android应用--创建列表和卡片
- 创建Material Design风格的Android应用--创建列表和卡片
- 【实例】表单跨页(内容在一个ActionForm)中保存
- 101 个 MySQL 的调节和优化的提示
- DLL文件——让我来管理(一)
- oracle 错误ORA-27300: OS system dependent operation:semctl failed with status: 22 ORA-00600: internal
- TCP序列号和确认号详解
- 创建Material Design风格的Android应用--应用主题
- 自制全铝CNC雕刻机全过程(完工篇)
- 一个国内的 ngrok 服务器
- HDU2444 The Accomodation of Students(二分匹配 匈牙利算法)
- Practical C Programming - Chapter 9
- 如何导入frm格式MYD格式MYI格式文件到MySQL中
- oracle 中的translate函数
- first Missing Positive number
- IOS缓存基本知识和清除缓存的方法