zoukankan      html  css  js  c++  java
  • Android UI ActionBar功能-自定义 Action Bar 样式

    ActionBar的样式官方提供了三种:

    Theme.Holo 

    Theme.Holo.Light

    Theme.Holo.Light.DarkActionBar


    但不仅仅是这三种,我们还可以自己定义ActionBar的样式:

    官方帮助文档地址:http://wear.techbrood.com/training/basics/actionbar/styling.html

    比如让ActionBar显示一个纯色的背景图片:






    首先导入文件:


    他是一个点9PNG类型的文件,可以使中间无限伸展而不变型,在AndroidUI 布局动画-点九PNG技术 中有说明;

    然后在values/下新建一个themes.xml文件,自定义ActionBar样式:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="CustomActionBarTheme"  parent="@android:style/Theme.Holo.Light.DarkActionBar">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
        </style>
        <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@drawable/actionbar_background</item>
        </style>
    </resources>
    注:自定义的ActionBar必须继承自官方默认提供的三种主题中的一种;

    然后在AndroidManifest.xml文件中将应用程序的主题更改为我们自定义的主题:

    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/CustomActionBarTheme" >



  • 相关阅读:
    爬虫基础 2.1 http原理
    爬虫基础 2.1 http原理
    3.29上午
    3.28
    3.27下午
    3.27上午
    3.24上午
    3.23下午
    3.23上午
    3.22上午
  • 原文地址:https://www.cnblogs.com/raphael5200/p/5114781.html
Copyright © 2011-2022 走看看