Android Snackbar Is Hidden Behind System UI

血红的双手。 提交于 2020-01-14 07:41:10

问题


I've got a full screen Activity that does a hide/show of the system UI using the following two functions:

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

Since the UI is laid out in full screen mode when I show a Snackbar and the System UI is showing, it is drawn behind the Navigation bar. I'm not using a CoordinatorLayout and currently have no reason to use it. What's the proper way to get the Snackbar to show in the correct place given the current state of the system UI?

来源:https://stackoverflow.com/questions/37311322/android-snackbar-is-hidden-behind-system-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!