0

大家好,我是 android studio 的初学者,我注意到当我在手机上运行我的应用程序时,状态栏和屏幕按钮都是可见的,但在我朋友的设备上没有状态栏或屏幕按钮所以它使用全分辨率,我怎样才能强制应用程序在所有设备上都有呢?我的手机和他手机的分辨率相同(1080x2340),但在他的手机上,它就像只是缩小了一样。有没有办法让应用程序在两台设备上都一样工作?我的意思是,分辨率相同,但由于状态栏/屏幕按钮,应用程序看起来不同。

4

1 回答 1

0
private void hideSystemUI() {
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    mDecorView.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 // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);
}

// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
    mDecorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
于 2020-10-01T14:36:31.323 回答