Android - 状态栏可防止全屏显示

时间:2010-06-19 04:54:06

标签: android layout fullscreen statusbar

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

这是我的布局:

<?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 个答案:

答案 0 :(得分:16)

您可以使用以下方法解决此问题:

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);
            }   
        }
    });

答案 1 :(得分:3)

答案 2 :(得分:0)

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

答案 3 :(得分:0)

我有同样的问题。我更改了插页式广告的活动并删除了: 机器人:主题=&#34; @android:风格/ Theme.Translucent&#34;

相关问题