【发布时间】:2014-06-13 17:29:09
【问题描述】:
我想从 ActionBar 中删除标题。这是我所做的:
我使用 first tutorial here 创建了一个 HelloWorld 应用程序。然后我尝试通过从 displayOptions 属性中删除 showTitle 标志来从 ActionBar 中删除标题。标题没有被删除。但是当我还设置android:label=" "时,标题被删除了,应用程序的名称也从应用程序启动器中删除。
如何仅从 ActionBar 中删除标题?
styles.xml
<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>
<style name="ActionBarNoTitle" parent="Widget.AppCompat.Light.ActionBar">
<item name="displayOptions">useLogo|showHome</item>
</style>
<style name="NoTitleActivityTheme" parent="AppTheme">
<item name="actionBarStyle">@style/ActionBarNoTitle</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.notitle"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.test.notitle.MainActivity"
android:label="@string/app_name"
android:theme="@style/NoTitleActivityTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
【问题讨论】:
标签: android android-activity android-actionbar android-actionbar-compat