码迷,mamicode.com
首页 > 移动开发 > 详细

Android ActionBar 返回为NULL

时间:2015-05-05 10:14:29      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

AndroidBar返回为NULL。是因为values-v11和values-v14下面的style的主题的设置的原因。

在SDK 11的设备上,会使用第二处,SDK 14会使用第三处。

技术分享

只需要将三个地方的主题分别设置就可以,结构如下:

values--------

<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

 

values-v11--------

 

<resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
        <!-- API 14 theme customizations can go here. -->
        <item name="android:actionBarStyle">@style/my_actionbar_style</item>
    </style>

    <style name="my_actionbar_style" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">#ff8c00</item>
        <item name="android:titleTextStyle">@style/AcBar_titleStyle</item>
        <item name="android:displayOptions">showTitle</item>
    </style>

    <style name="AcBar_titleStyle">
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textSize">20sp</item>
    </style>

    <style name="AppTheme" parent="AppBaseTheme"></style>
</resources>

 

values-v14--------

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
        <item name="android:actionBarStyle">@style/my_actionbar_style</item> 
    </style>

    <style name="my_actionbar_style" parent="@android:style/Widget.Holo.Light.ActionBar">  
        <item name="android:background">#ff8c00</item>  
        <item name="android:titleTextStyle">@style/AcBar_titleStyle</item>
         <item name="android:displayOptions">showTitle</item>
    </style>
    <style name="AcBar_titleStyle">    
        <item name="android:textColor">#FFFFFF</item>
        <item name="android:textSize">20sp</item>  
    </style>
    <style name="AppTheme" parent="AppBaseTheme"></style>
</resources>

 

主要注意红色部分

Android ActionBar 返回为NULL

标签:

原文地址:http://www.cnblogs.com/android-joker/p/4478363.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!