10

I want to hide the title bar (where the activity tile is shown) in my application. I'm doing this by setting the android:windowNoTitle item to true. This works fine for devices with API level 19. I tested it with a device running API level 10 and it only hides the notification bar. The tile bar is still shown.

Here is my res/values/styles.xml

<resources>
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>

</resources>

EDIT: I'm using the AppBaseTheme as the theme in my manifest. There are no other styles.xml files in any other value-vXX folder.

Edit#2: I'm extending an ActionBarActivity for my activity.

CJBS
  • 15,147
  • 6
  • 86
  • 135
Armin
  • 351
  • 1
  • 4
  • 29
  • 3
    add `requestWindowFeature(Window.FEATURE_NO_TITLE);` before setContentView(layout) in your onCreate() method. and For full screen use `getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);' – Kunu May 17 '14 at 07:58
  • same result. not working under gingerbread. – Armin May 17 '14 at 08:09
  • 1
    It seems you are using **2 different theme names** (`AppTheme` and `AppBaseTheme`). And the themes **don't differ**. So, not only it's useless to have 2 themes, but the names should be identical. – Phantômaxx May 17 '14 at 08:22
  • @DerGolem ok. I tried it with one theme (only the `AppBaseTheme`). Stil not working – Armin May 17 '14 at 08:33
  • I use 1 theme for all the devices and it works perfectly on API level 8 to 16 (since I only have 5 physical devices). I'm sure it's working on 17-19 devices too – Phantômaxx May 17 '14 at 08:37
  • @DerGolem I'm using now only one styles.xml with only one theme and it doesn't work. Only the full screen mode seems to work on gingerbread – Armin May 17 '14 at 08:43
  • In your Manifest file (in the application section), is there a line like `android:theme="@style/AppTheme"`? – Phantômaxx May 17 '14 at 08:45
  • @DerGolem Yes, `AppBaseTheme`, because I deletet the other one. And as said, it works on api level 19, without any settings in the `Activity`. – Armin May 17 '14 at 08:48
  • Very strange. It MUST work... Did you remove the other themes/styles in your `values-xy` folders? – Phantômaxx May 17 '14 at 08:49
  • @DerGolem yes. There's only one values.xml file. – Armin May 17 '14 at 08:59
  • I find it really surprising. Try doing a Project/Clean. Then you can try an Eclipse restart. – Phantômaxx May 17 '14 at 09:00
  • @DerGolem Done: clean + restart + clean => install. no changes. – Armin May 17 '14 at 09:05
  • Did you also add the suggested code by Kunu? – Phantômaxx May 17 '14 at 09:06
  • @DerGolem Yes, I tried that. same result. PS: updated the Question to the new situation. – Armin May 17 '14 at 09:09
  • Try using this line: `parent="android:style/Theme.NoTitleBar.Fullscreen"` instead of `true` (I just compared it with my **working** theme). – Phantômaxx May 17 '14 at 09:13
  • @DerGolem This won't work for me, because I use a `ActionBarActivity` and that needs a `AppCompat` theme. – Armin May 17 '14 at 09:18
  • But the AppCompat theme is **NOT full screen**, by definition. So, the StatusBar will go away, but not the TitleBar – Phantômaxx May 17 '14 at 09:26
  • @DerGolem so there's no way around extending an standard Activity? – Armin May 17 '14 at 09:27
  • @DerGolem But why does it work then on api level 19? – Armin May 17 '14 at 09:28
  • I don't uderstand if you need the ActionBar or not... – Phantômaxx May 17 '14 at 09:34
  • @DerGolem No, just using it because it was added by default. – Armin May 17 '14 at 09:35
  • 1
    `just using it because it was added by default` - Bad practice! I'd remove it as soon as possible. – Phantômaxx May 17 '14 at 09:36
  • @DerGolem Yes, I will do so. I thought this was "the new way of doing it" and an standard `Activity` doesn't get used any more. Thanks ;) – Armin May 17 '14 at 09:39
  • No, no... don't bloat your apps with `unneeded` and `unwanted` things. – Phantômaxx May 17 '14 at 09:40
  • I have a Header Bar and a Footer Bar, but these are simply RelativeLayouts I implemented **my own**. And still have the freedom of using the whole screen surface. – Phantômaxx May 17 '14 at 09:42
  • @DerGolem Woud you mind posting this as answer? – Armin May 17 '14 at 09:44
  • OK, it took me a while to collect the comments and make asenseful answer out of them... ;) – Phantômaxx May 17 '14 at 09:52

3 Answers3

15

try using this

<style name="MyMaterialDialog" parent="Base.Theme.AppCompat.Light.Dialog.MinWidth">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

remove android prefix!

ali
  • 411
  • 5
  • 15
1

I tried the android:style/Theme.NoTitleBar.Fullscreen in styles.xml but I got:

Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

So I followed the advise to stick to the AppCompat theme, and could hide statusbar and actionbar using the following lines in styles.xml:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
    </style>
</resources>
Avatar
  • 14,622
  • 9
  • 119
  • 198
0

I use 1 theme for all the devices and it works perfectly on API level 8 to 16 (since I only have 5 physical devices). I'm sure it's working on 17-19 devices too.

Make sure that in your Manifest file (in the application section), there is a line like android:theme="@style/AppTheme"

Try using this for your theme:

<style
    name="AppBaseTheme"
    parent="android:style/Theme.NoTitleBar.Fullscreen"
    >
    <item name="android:windowNoTitle">true</item>

    ...

</style>

And remove the styles/themes in the values-xy folders

[EDIT]

Since the AppCompat theme is NOT full screen, by definition, the StatusBar will go away, but not the TitleBar

If you don't need the ActionBar offered by the AppCompat, then you should get rid of the AppCompat as soon as possible: don't bloat your apps with unneeded and unwanted things

For instance, I have a Header Bar and a Footer Bar, but these are simply RelativeLayouts I implemented my own.
And still have the freedom of using the whole screen surface.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115