如果我将主题应用于整个应用程序,它会成功隐藏 ActionBar 标题:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
</resources>
在清单中分配:
<application
android:name="myapp"
android:allowBackup="true"
android:icon="@drawable/action_bar_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
我需要将 ActionBar 标题隐藏在一项活动.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
...other things...
</style>
<style name="MainActivityTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome|useLogo</item>
</style>
</resources>
为一项活动明确设置此主题:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:theme="@style/MainActivityTheme">
它仍然显示标题MainActivity
ActionBar
。我知道如何在 java 中隐藏标题,我需要知道我在 XML 中做错了什么。
在清单中设置活动的主题。
<activity
android:name=".MyActivity"
android:theme="@style/MainActivityTheme" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)