Hide notification bar without using fullscreen
Asked Answered
A

3

2

Here is my problem: is it possible to hide the android notification bar without using the fullscreen flag? I need to adjustResize my app when the soft keyboard is shown, but fullscreen apps ignore the resizing (as far as i know).

Has anyone an idea on how to make my app look fullscreen without this flag?

Here is the problem with the fullscreen flag: it only tries to show everything important, but i need to resize my app:

enter image description here

enter image description here

and the xml:

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:text="EditText1"/>

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="EditText2" />

</RelativeLayout>

Summary: i expected to see both EditTexts after my app resized and the new dimensions are redrawn

Anchor answered 13/1, 2012 at 13:15 Comment(4)
I think you only can do it with fullscreen flag like here: https://mcmap.net/q/334976/-hide-notification-barIgnaciaignacio
hmmm. so it will end up in a lot of ugly workarounds, to resize my app on keyboard appearance. too bad :( but thx anywayAnchor
what adjustResize value are you using?Underbelly
stateHidden|adjustResizeAnchor
R
0

This is a known and not fixed Android bug, try out the workaround here

All credit to LEO

Ravishing answered 6/11, 2012 at 15:41 Comment(6)
thx for searching. Unfortunately the "toggleing" is no acceptable solution in my usecaseAnchor
Why not? This is an OS bug, you will not find pretty answers.Ravishing
i know, that there (maybe) won't be an "perfect solution. But the toggeling shows and hides the statusbar, which is unfortunately an unacceptable effect for my customer. Ofc this is the best solution (and the fastest) so far, so I think you will be my bounty winner. (except someone else will post a better solution)Anchor
It's a shame, you might want to argue the hiding of the notification bar, leaving it may be the better option. Leaving the notification bar visible is very common.Ravishing
Yeah I think so too. the only problem is, that the current version has the notification bar visible and a lot of user requested to hide it. So i hoped to find a solution to make my customer and the users happy. But i guess they have to live with it the way it is.Anchor
They'd be complaining more with scrolling or flashing notification bars ;)Ravishing
D
1

This can help:

getWindow().addFlags( WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN );
getWindow().addFlags( WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS );

You can add this to the beginning of your onCreate().

Additional comments can be found in this answer: https://mcmap.net/q/36361/-android-how-to-adjust-layout-in-full-screen-mode-when-softkeyboard-is-visible

Disjunct answered 6/11, 2012 at 15:46 Comment(5)
thx. Unfortunately the "toggleing" is no acceptable solution in my usecaseAnchor
Could you, please, elaborate why?Disjunct
i know, that there (maybe) won't be an "perfect solution. But the toggeling shows and hides the statusbar, which is unfortunately an unacceptable effect for my customer.Anchor
But you can use toggling only once, in the beginning.Disjunct
first: i misread your answer and thought it was a copy of guykuns. But after trying your code i saw, that adding the code in onCreate() made my app didn't resize at all (but it isn't scrolling to my bottom EditText anymore)Anchor
T
0

Hmmm, I think fullscreen also support resize,

you can do it like this in your Manifest

    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" 
    android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" 
    android:windowSoftInputMode="stateHidden|adjustResize"
    android:screenOrientation="portrait" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

enter image description here

enter image description here

Thirty answered 6/11, 2012 at 8:23 Comment(5)
NoTitleBar != Fullscreen. I need to hide the notification bar and NoTitleBar won't do that.Anchor
@Sprigg, how did you make your activity fullscreen?Psalms
Sorry, fix my answer I still confirm it. fullscreen can resize.Thirty
unfortunately it just aligns the app. Look in my original post for some screenshots and the xmlAnchor
@Landry: At the moment i didn't make it fullscreen at all because i couldn't solve the problem and that is definitely a show stopper in my scenario. But i tried doing it by using a android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" in the manifestAnchor
R
0

This is a known and not fixed Android bug, try out the workaround here

All credit to LEO

Ravishing answered 6/11, 2012 at 15:41 Comment(6)
thx for searching. Unfortunately the "toggleing" is no acceptable solution in my usecaseAnchor
Why not? This is an OS bug, you will not find pretty answers.Ravishing
i know, that there (maybe) won't be an "perfect solution. But the toggeling shows and hides the statusbar, which is unfortunately an unacceptable effect for my customer. Ofc this is the best solution (and the fastest) so far, so I think you will be my bounty winner. (except someone else will post a better solution)Anchor
It's a shame, you might want to argue the hiding of the notification bar, leaving it may be the better option. Leaving the notification bar visible is very common.Ravishing
Yeah I think so too. the only problem is, that the current version has the notification bar visible and a lot of user requested to hide it. So i hoped to find a solution to make my customer and the users happy. But i guess they have to live with it the way it is.Anchor
They'd be complaining more with scrolling or flashing notification bars ;)Ravishing

© 2022 - 2024 — McMap. All rights reserved.