8

我的应用程序在启动时正确地全屏运行。然而,在最小化然后返回应用程序后,状态栏会弹出并将我的视图向下推一点。如何防止状态栏移动我的视图?

这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.example.draw"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
    <com.example.draw.DrawView 
        android:id="@+id/draw"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:visibility="visible"
        android:fitsSystemWindows="false"
    />      
<com.admob.android.ads.AdView     
       android:id="@+id/ad" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"
       myapp:backgroundColor="#000000"
       myapp:primaryTextColor="#FFFFFF"
       myapp:secondaryTextColor="#CCCCCC"
       android:layout_gravity="bottom"
/>     

这是我活动的 onCreate 的一部分:

requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);  

我在清单中也有全屏主题:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

谢谢

4

4 回答 4

17

您可以通过以下方式解决此问题:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

(在 onCreate 中执行此操作)....请注意,这将破坏软键盘 (IME) - 因为 edittext 不能再滑入键盘上方的视图中。该标志完全阻止窗口移动......

如果您需要编辑文本在修复状态错误时也可以工作,您可以这样做

someEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            } else {
                hideKeyboard();
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
            }   
        }
    });
于 2011-01-20T01:39:52.600 回答
3

状态栏/通知栏存在已知错误。

看:

http://code.google.com/p/android/issues/detail?id=3674

http://code.google.com/p/android/issues/detail?id=8052

http://code.google.com/p/android/issues/detail?id=5906

于 2010-06-19T15:58:22.717 回答
0

只需 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 清单上的活动属性就足够了。希望它的作品

于 2010-06-19T08:27:40.790 回答
0

我遇到过同样的问题。我更改了插页式的活动并删除了:android:theme="@android:style/Theme.Translucent"

于 2014-12-01T12:53:41.460 回答