Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:windowNoTitle will not hide actionbar with appcompat-v7 21.0.0

I updated appcompat-v7 to lollipop version(21.0.0)

then I can't hide ActionBar with following style that worked before.

<style name="AppTheme.NoActionBar">
    <item name="android:windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

I set it to specific activity.

<activity android:name=".NoActionBarActivity"
        android:theme="@style/AppTheme.NoActionBar"/>

When I use appcompat-v7 20.0.0 version, actionbar will be hidden as it is intended.

How can I hide actionbar with custom style with AppCompat version 21 library?

like image 706
Chk0nDanger Avatar asked Nov 12 '14 02:11

Chk0nDanger


People also ask

How to remove ActionBar in android studio?

If we want to remove the ActionBar only from specific activities, we can create a child theme with the AppTheme as it's parent, set windowActionBar to false and windowNoTitle to true and then apply this theme on an activity level by using the android:theme attribute in the AndroidManifest. xml file.

How to Hide Action Bar title in android?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme.


2 Answers

@Chk0nDanger your answer is true but you should use below code :

<style name="Theme.AppCompat.NoActionBar" parent="Theme.AppCompat.Light">
   <item name="windowActionBar">false</item>
   <item name="android:windowNoTitle">true</item>
</style> 

without parent element, everything will be white color (textviews,buttons,chekcboxs, etc)!

in your manifest.xml file :

    <activity android:name=".MyClass"
        android:theme="@style/Theme.AppCompat.NoActionBar"
        />

updated 2015 29 July

make sure android:windowNoTitle should be replaced by windowNoTitle when Upgraded to AppCompat v22.1.0

like image 51
S.M_Emamian Avatar answered Sep 29 '22 04:09

S.M_Emamian


OK, I found the answer.

There is Theme.AppCompat.NoActionBar theme in appcompat-v7:21.0.0. It is defined as following.

<style name="Theme.AppCompat.NoActionBar">
   <item name="windowActionBar">false</item>
   <item name="android:windowNoTitle">true</item>
</style>

There is no android prefix in windowActionBar attribute.

like image 41
Chk0nDanger Avatar answered Sep 29 '22 03:09

Chk0nDanger