Android Snackbar隐藏在系统UI背后

时间:2016-05-18 22:50:37

标签: android snackbar android-immersive

我有一个全屏活动,使用以下两个功能隐藏/显示系统UI:

// This snippet hides the system bars.
public static void hideSystemUI(View view) {
    // 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.
    view.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.
public static void showSystemUI(View view) {
    view.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

由于当我显示Snackbar并且系统UI正在显示时,UI以全屏模式布局,因此它将在导航栏后面绘制。我没有使用CoordinatorLayout,目前没有理由使用它。在给定系统UI的当前状态的情况下,将Snackbar显示在正确位置的正确方法是什么?

0 个答案:

没有答案