使用全屏活动 [英] Using full screen Activity
问题描述
我正在做一个简单的游戏,到目前为止,我一直在使用空白活动。现在,我希望它覆盖整个屏幕,是否需要使用全屏活动重新编码整个内容?我曾尝试在网上寻找东西,但遇到的每件事都添加了以下内容:
I am making a simple game and so far I've been using the Blank Activity. Now I want it to cover the entire screen, Will I need to Recode the entire thing using a FullScreen Activity? I've tried looking for something online but every thing i came across had adding this bit:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
应用在设备上启动后立即崩溃。所以,请有人告诉我我的错误。
Which causes the app to crash as soon as it is launched on a device. SO please if anyone can show me my error.
这里是指向logcat输出以及游戏代码的链接
Here is a link to the logcat output as well as the game code
推荐答案
尝试将活动设置为全屏:
Try this to set activity to fullscreen:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
您可以将此代码放入 onCreate()
方法
You can put this code in onCreate()
method
这篇关于使用全屏活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!