Android - 状态栏阻止全屏
我的应用程序启动时可以全屏正确运行。然而,在最小化然后返回应用程序后,状态栏会弹出,并将我的视图稍微向下推。如何防止状态栏移动我的视图?
这是我的布局:
<?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"
谢谢
My app correctly runs in full screen when it's started. However after minimizing and then returning to the app, the status bar pops up and pushes my views down a little. How can I keep the status bar from moving my views?
Here is my layout:
<?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"
/>
Here is part of my activity's onCreate:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
I also have the fullscreen theme in the manifest:
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以通过以下方式解决此问题:(
在 onCreate 中执行此操作)...请注意,这将破坏软键盘 (IME) - 因为 edittext 无法再滑入键盘上方的视图中。 该标志完全阻止窗口移动......
如果您需要编辑文本来同时修复状态错误,您可以这样做
You can fix this issue with:
(do that in onCreate).... note that this will break the soft keyboard (IME) - as edittext can no longer slide into view above the keyboard. That flag prevents the window from moving at all....
If you need an edit text to also work while fixing the status bug you can do
状态栏/通知栏存在已知错误。
请参阅:
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
There are known bugs with the status bar / notification bar.
See:
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
只需清单上活动的 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 属性就足够了。希望它的作品
Just android:theme="@android:style/Theme.NoTitleBar.Fullscreen" attribute on your activity on the manifest is enough. Hope its works
我有同样的问题。我更改了插页式广告的活动并删除了:
android:主题=“@android:style/Theme.Translucent”
I had the same issue. I changed the activity for the interstitial and deleted:
android:theme="@android:style/Theme.Translucent"