如何请求权限或在设置上自动设置手机的全屏-Android Studio [英] How to ask permission or automatically set the phone's full screen on settings - android studio
问题描述
我正在尝试使用以下代码将我的活动设置为全屏显示:
I am trying to set my activity to full screen using this code below:
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| 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);
}
但是由于设置条件,我在某些手机上出现黑色导航栏->显示某些电话需要允许应用程序使用全屏模式的位置.为了解决此问题,我决定在活动膨胀时需要实现权限检查器.如果还有其他方法,请告诉我,我将尝试实现.
But I am getting a black color navigation bar on certain phones because of the condition on settings -> display where certain phones need to permit apps to use a fullscreen mode. To address this issue I decided that I need to implement a permission checker when the activity inflates. If there is another way please tell me and I will try to implement it.
这是我正在谈论的电话的条件链接: https://www.gottabemobile.com/how-to-enable-full-screen-apps-on-galaxy-s10/
Here is the link of the conditions for phones that I am talking about: https://www.gottabemobile.com/how-to-enable-full-screen-apps-on-galaxy-s10/
推荐答案
在清单文件中放入
android:theme ="@ style/Theme.Design.NoActionBar"
或
android:theme="@style/AppTheme"
,然后在您的活动中调用 hideSystemUI()
;设置内容视图之前像这样:
and in your activity call hideSystemUI()
; before setting the content view
like this :
final int flags = 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;
getWindow().getDecorView().setSystemUiVisibility(flags);
setContentView(R.layout.activity_main);
这篇关于如何请求权限或在设置上自动设置手机的全屏-Android Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!