Android Studio屏幕设置

问题描述

大家好,我是android studio的初学者, 我注意到当我在手机上运行我的应用程序时,状态栏以及屏幕上的按钮都可见,但是在我朋友的设备上没有状态栏或屏幕上的按钮,因此它使用完整分辨率,我该如何强制该应用程序在所有设备上都具有?我的手机和他的手机的分辨率是相同的(1080x2340),但在他的手机上就像是缩小了。 有没有一种方法可以将应用设置为在两个设备上都可以正常工作?我的意思是,分辨率是相同的,但是由于状态栏/屏幕上的按钮,该应用看起来有所不同。

解决方法

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