Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding/showing Status Bar without animation

Tags:

android

I need to show / hide status bar in the same Activity(Fragment) for API 17+. Let's say one button will hide it, the other one will show it:

Show:

getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

Hide:

getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                       WindowManager.LayoutParams.FLAG_FULLSCREEN);

This works fine, but there is a "slide up-down" animation when it changes for full screen - not fullscreen. How to remove this animation? I want status bar to disappear immediately, I've tried with:

requestWindowFeature(Window.FEATURE_NO_TITLE);

But nothing happened, it is still showing up with animation, I've also read:

how to remove statusbar animation when changing to fullscreen in Android https://groups.google.com/forum/#!topic/android-developers/hS1twXVoorc

like image 890
Djordje Tankosic Avatar asked Feb 27 '15 23:02

Djordje Tankosic


People also ask

How can I hide status bar in Samsung?

Note the bright red line on the bottom of the screen. To restore the navigation buttons and status bar, slide up the red line at the bottom of the screen. To again disable the status bar, fire the third rectangle icon or tap the red line.

What is status bar in phone?

On Android, the status bar contains notification icons and system icons.


1 Answers

Have you tried using this attribute in the activity or fragment layout, ideally under the root view

android:animateLayoutChanges="false"
like image 153
Niladree Avatar answered Oct 04 '22 14:10

Niladree