Android的动作条的风格被后来的设备被忽略,使用appcompat V7 [英] Android actionbar style ignored by later devices, using appcompat v7

查看:131
本文介绍了Android的动作条的风格被后来的设备被忽略,使用appcompat V7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的操作栏支持库(appcompat V7),我的应用程序设置为7的最小API,以及21个目标。

I am using the Action Bar support library (appcompat v7), my app is set to a minimum api of 7, and a target of 21.

我有两个样式文件,一个基地之一,以及一个针对设备的API 11 +。

I have two styles files, a base one, and one targeted at devices api 11+.

在运行运行奇巧设备上的应用程序,它似乎安卓actionBarStyle 被忽略,留下称呼为默认值(@风格/ Widget.AppCompat操作栏。而不是采用给定的背景ActionBar.Solid)。

When running the app on a device running KitKat, it seems that android:actionBarStyle is ignored, leaving the action bar styled as default (@style/Widget.AppCompat.ActionBar.Solid), instead of applying the given background.

但是,如果我删除我的V11款式/他们注释掉,奇巧监听 actionBarStyle 属性在基本styles.xml文件中设置,并设置我的自定义背景,没有任何问题

But if I remove my v11 styles/comment them out, KitKat listens to the actionBarStyle attribute set in the base styles.xml file and sets my custom background without any problems.

所以我的问题,我要去哪里错了V11的风格?

据我了解,根据android的文档,你应该提供额外的样式运行11+使用 Android设备: preFIX,但这似乎并不要为我工作。

From what I understand, according to the android docs, you are supposed to supply the additional styles for devices running 11+ using the android: prefix, but this just doesn't seem to be working for me.

剥了下来,这是我的 /res/values​​/styles.xml 文件:

Stripped down, this is my /res/values/styles.xml file:

<style name="My.Theme" parent="@style/Theme.AppCompat">
    <item name="actionBarStyle">@style/ActionBar.Solid</item>
</style>

<style name="ActionBar.Solid" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_</item>
</style>

这是我的 /res/values​​-v11/styles.xml 文件:

<style name="My.Theme" parent="@style/Theme.AppCompat">
    <item name="android:actionBarStyle">@style/ActionBar.Solid</item>
</style>

<style name="ActionBar.Solid" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="android:background">@drawable/ab_solid_</item>
</style>

你可以看到,两者之间的唯一区别是使用了机器人的: preFIX

as you can see, the only difference between the two is the use of the android: prefix.

推荐答案

根据官方文档,与 AppCompat-V21,你可以删除所有的值,V14 +操作栏的样式,只有一个用主题的宣言,在

According to the official doc, with the new AppCompat-v21, you can remove all of values-v14+ Action Bar styles and use only one theme declaration, in values:

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
    <!-- Set AppCompat’s actionBarStyle -->
    <item name="actionBarStyle">@style/MyActionBarStyle</item>
</style>

这篇关于Android的动作条的风格被后来的设备被忽略,使用appcompat V7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆