5
votes

I have been searching the answer about this question for two days but I didnt find.

I'm trying to hide the action bar in order to show an image properly, but whenever I hide/show the action bar the activity show a white space at the bottom. I know that it happens because the window resize on hide/show action bar event, also that is a default animation from Android, but I need to change that color (black color) or not show this white space. But how can I do it?

I've tried to set the activity background in black, but it still not working.

E.g. USA Today app do it at the section "Day in pictures"

Please any help is apreciated!

Thanks in advance.

3

3 Answers

1
votes

Have you tried setting the action bar to overlay the content area instead of resting on top of it? In your onCreate(), add this at the top just after calling super.onCreate():

getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
0
votes

this code worked for me like a charm

// This snippet hides the system bars.
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.
    View decorView = getWindow().getDecorView();
    decorView.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);
}

private void showSystemUI() {

    //make nav bar transparent
    Window window = getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

    View decorView = window.getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
-3
votes

There should be no need to do what Karakuri suggests; hide all menu items in the action bar and the bar will disappear.