Hide notification bar without using fullscreen

2019-05-27 09:53发布

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

3条回答
Lonely孤独者°
2楼-- · 2019-05-27 10:32

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

查看更多
我想做一个坏孩纸
3楼-- · 2019-05-27 10:34

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://stackoverflow.com/a/10952394/1065190

查看更多
别忘想泡老子
4楼-- · 2019-05-27 10:44

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

All credit to LEO

查看更多
登录 后发表回答