Android 主题不应用于仿真器设备
我有一个活动和一个布局应用程序。我正在实现ActionBarSherlock,但我的主题不适用于我的模拟器/早期设备 My theme.xml:Android 主题不应用于仿真器设备,android,android-layout,android-actionbar,actionbarsherlock,android-theme,Android,Android Layout,Android Actionbar,Actionbarsherlock,Android Theme,我有一个活动和一个布局应用程序。我正在实现ActionBarSherlock,但我的主题不适用于我的模拟器/早期设备 My theme.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <!-- the theme applied to the application or activity --> <style name="CustomActivityTheme" pare
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActivityTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- other activity and action bar styles here -->
</style>
<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundSplit">#4200ff</item>
<item name="android:backgroundStacked">#4200ff</item>
<item name="android:background">#4200ff</item>
</style>
</resources>
@样式/MyActionBar
#4200ff
#4200ff
#4200ff
这会导致我的JellyBean设备上的ActionBar变为蓝色,但在我的2.2模拟器上它保持黑色
下面是my manifest.xml中的一段:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomActivityTheme">
在Android 3.0版及更高版本中,您可以将主题指定给项目名称
Android:actionBarStyle
。但在2.3及更早版本中,没有操作栏,因此不能使用名为android:actionBarStyle
的项。要修复此ActionBar,Sherlock已定义了它自己的项目名称,只需actionBarStyle
,不带android前缀。所以你的代码应该是这样的
@样式/MyActionBar
@样式/MyActionBar
#4200ff
#4200ff
#4200ff
嗯。。。现在酒吧从黑色变成了灰色。有什么想法吗?我是否需要将
#4200ff
中的任何内容更改为#4200ff
?是的,我上面提到的更改完成了。你知道把这两行都包括进去是否更好吗?或者只是其中一个?感谢您需要动作栏样式的android:backgroundSplit
和backgroundSplit
。另外,pre Honeycomb上的ColorDrawable
中有一个bug,它会导致分割的背景覆盖常规操作栏的背景。
<!-- the theme applied to the application or activity -->
<style name="CustomActivityTheme" parent="Theme.Sherlock">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<!-- other activity and action bar styles here -->
</style>
<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="android:backgroundSplit">#4200ff</item>
<item name="android:backgroundStacked">#4200ff</item>
<item name="android:background">#4200ff</item>
</style>