Android 安卓3.0+;动作栏在设置样式时保留背景
我正在为Android 3.0+开发一个应用程序,我想通过删除标题对动作栏进行个性化设置,我可以做到这一点,我的问题是我也会丢失动作栏的背景,我只想删除标题并保留剩余的样式。以下是我目前正在使用的内容:Android 安卓3.0+;动作栏在设置样式时保留背景,android,styles,android-actionbar,android-3.0-honeycomb,titlebar,Android,Styles,Android Actionbar,Android 3.0 Honeycomb,Titlebar,我正在为Android 3.0+开发一个应用程序,我想通过删除标题对动作栏进行个性化设置,我可以做到这一点,我的问题是我也会丢失动作栏的背景,我只想删除标题并保留剩余的样式。以下是我目前正在使用的内容: <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/v
<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="android:Theme.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. -->
<item name="android:actionBarStyle">@style/ActionBarNoTitle</item>
</style>
<style name="ActionBarNoTitle" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
</resources>
@风格/动作
showHome | useLogo
我不希望更改活动代码来完成此任务。您使用的主题是什么?这可能是在
values-v11
或values-v14
中定义的。如果Theme.Holo.Light
您必须将actionBarStyle
的父样式更改为Widget.Holo.Light.ActionBar.Solid
<style name="ActionBarNoTitle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
showHome | useLogo
你试过这个吗
在theme.xml文件中定义此项
<style name="CustomActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/NoTitleText</item>
<item name="android:subtitleTextStyle">@style/NoTitleText</item>
</style>
<style name="NoTitleText">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#00000000</item>
</style>
@样式/自定义操作栏样式
在style.xml文件中定义它
<style name="CustomActionBar" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>
<style name="CustomActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/NoTitleText</item>
<item name="android:subtitleTextStyle">@style/NoTitleText</item>
</style>
<style name="NoTitleText">
<item name="android:textSize">0sp</item>
<item name="android:textColor">#00000000</item>
</style>
@样式/NoTitleText
@样式/NoTitleText
0sp
#00000000
让我知道这是否有效。谢谢,它有效,但这需要minSDK 14,如果可能的话,我更喜欢11。对于
v11
,它是Widget.Holo.Light.ActionBar
。我会将此标记为正确答案,尽管问题是v11
不支持暗操作栏,我不知道,我的缺点是,考虑到只有0.1%的设备运行蜂巢,我将把minsdk改为14。谢谢你的时间。它确实有效,我尝试过这个解决方案,但考虑到有一个更干净的方法,它看起来有点脏。它还利用了api 11中的主题。无论如何,谢谢你:)