If I apply theme for whole application it hides ActionBar title successfully:
<?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>
assign in manifest:
<application
android:name="myapp"
android:allowBackup="true"
android:icon="@drawable/action_bar_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
I need ActionBar title hidden just in one activity.
<?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>
setting this theme explicitly for one activity:
<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">
and it still shows title in MainActivity
ActionBar
. I know how to hide the title in java, I need to know what I do wrong here in XML.
You probably want to create a sub-theme which hides the action bar:
and then apply it to your activity in the manifest like so:
Using the dot notation (
AppTheme.NoActionBar
) makes thisNoActionBar
theme inherit everything fromAppTheme
and override the setting onandroid:windowActionBar
. If you prefer you can explicitly note the parent:Also, if you're using the AppCompat libraries, you probably want to add a namespace-less version to the sub-theme.
If you want to remove
actionbar title
then just removelabel
attribute from<activity>
tag in yourmanifest
file.Such as,
And after removing,
Done!
Set the theme on your activity in the manifest.