zoukankan      html  css  js  c++  java
  • 创建Material Design风格的Android应用--应用主题

    本人全部文章首先公布于个人博客,欢迎关注,地址:http://blog.isming.me

    昨天正式公布了android 5,同一时候android developer站点也更新了,添加了创建Material Design风格的Android应用指南,也更新了Support Library,在support library添加了一些Material Design风格的控件和动画等,这里给大家简介一下如何开发material design风格的Android应用。

    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
    Light material theme

    Light material theme

    Dark material theme
    Dark material theme

    Dark material theme

    我们能够以这三个Theme来定义我们的Theme,比方:

     <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>

    我们能够改动每一个位置的字或者背景的颜色,每一个位置的名字例如以下图所看到的:

    Customizing the material theme
    Customizing the material theme

    我就简单的介绍一下,更详细的自己探索吧。

    较低版本号使用Material Design风格

    要在较低版本号上面使用Material Design风格,则须要使用最新的support library(version 21)。能够直接把项目引入project,或者使用gradle构建。添加compile dependency:

    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。例如以下:

    <!-- 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,可是因为低版本号不支持沉浸式状态栏,有一些效果还是无法实现。

    PS:就写这么多吧。下次写使用CardView 和RecyclerView。做Material Design的List 和Card布局。

     (我英文不好。可能有些地方也理解的不好。)

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

    原文地址:http://blog.isming.me/2014/10/18/creating-android-app-with-material-design-one-theme/,转载请注明出处。

  • 相关阅读:
    @RequestParam注解使用:Name for argument type [java.lang.String] not available, and parameter name information not found in class file either.
    cglib动态代理导致注解丢失问题及如何修改注解允许被继承
    springboot Autowired BeanNotOfRequiredTypeException
    git根据用户过滤提交记录
    不同包下,相同数据结构的两个类进行转换
    How to use Jackson to deserialise an array of objects
    jooq实践
    java如何寻找main函数对应的类
    Python--matplotlib
    Python 和 Scikit-Learn
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/7248256.html
Copyright © 2011-2022 走看看