Hide status bar when using a YoutubeFragment (YoutubePlayer android API) - android

I have a fullscreen project, and am hiding the statusbar using
getWindow ().setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
in the main activity's onCreate.
This works, and hides the status bar just fine, until I add a YoutubeFragment and play a video. The moment the video loads, the status bar drops down, very annoying. I tried setting the flags all over the onInitializationSuccess listener, but no dice. The documentation doesn't mention the status bar on any non-full screen layout changes at all: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment
Anyone any ideas?
Thanks in advance.

I don't know if you can put in manifest to hide action bar.
But try this function of Activity class
getActionBar().hide();

I was using a android 4.4.2 device to test with. With 4.1+ or higher there's another way to hide the status bar dynamically : http://developer.android.com/training/system-ui/status.html#41
//4.1+ Specific hiding of status bar
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
I do not have the problem with the status bar popping up when adding a YoutubeFragment. Why the old code didn't work with YoutubeFragments, or even setting the Theme to
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen"
, I have no idea though.

Related

Completely Transparent Status Bar doesn't work on some devices

Hi I am trying to develop a page with completely transparent status bar and white Navigation bar. I am using
getWindow().getDecorView().setSystemUiVisibility( SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
In fragment.xml in parent layout I have used
android:fitsSystemWindows="true"
But it is not working on some devices. It is showing an overlay in status bar on some devices.Though, it is working fine on some devices. Please help me out this.
I have also tried setting Full screen flag but it causes my status bar font to disappear.
I have also used statusBarUtil library but it causes navigation bar to turn black.
Try this to hide the ActionBar:
getSupportActionBar().hide();
using immersive mode
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
more information check it out:
https://developer.android.com/training/system-ui/immersive

how to hide the status bar from all layouts?

I want to hide the statusbar from all layouts on click of button.That button i have define in setting layout. But on click of hide button the status bar of current layout is getting hide but on other layout is unaffected.So let me know how to implement it on all the layouts of mu app.
Create a superclass for all Activities, call it something like BaseActivity or AbstractActivity and make each activity extend this class
In the onCreate, before setContentView, read from a database like SharedPreferences whether the status bar should be hidden. If so, then hide it.
In your Settings activity, call recreate() so that each onCreate from the previous activities are called again.
It actually depends on the version of android you are using. For example in Android 4.0 and lower you can achieve it by doing:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
For full documentation go to: https://developer.android.com/training/system-ui/status
Edit: What would be better for your button is this code:
void HideStatusBar() {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
So, when the user clicks the button call this function. Remember this also hides the action bar or toolbar, so if you don't want that remove the actionbar.hide() part. It's nice, but unfortunately, it only works on Android 4.1 and higher, so if you are supporting lower versions too better look at the documentation for clues. Hope it helps!

how control navigation bar and button in splash

Android
Hello.
I want to adjust the size of devices resolution and splash image in the splash screen.
I did try to apply png file to 9patch.
But I made gap between device to navigation bar.
And I'd try, try, try, I have reached this point.
I don't know how control navigation bar and button.
Please please please, teach me how hide navigation bar in the splash screen or how change the color in navigation bar's buttons.
Kindly review and give feedback.
It would be better to have some code so we can suggest what could be improved.
But here is some suggestions from android developer documentation.
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
read more here on how to hide navigation bar.
Link

Removing status bar

I have an Android 5.1 tablet with root. I'm implementing an app in kiosk mode. For that I'm using the immersive mode, which nicely hides the navigation and status bar. But with a swipe these bars reappears, which is not what I want.
With adding qemu.hw.mainkeys=0 to the end of the build.prop file I was able to get rid of the navigation (bottom) bar. Unfortunately, the status bar still re-appears when i pull down from the upper side of the screen.
Is there a possibility to get rid of the status bar by editing the builds.prop file or in another way?
Not so familiar with root device, so i think about different way, have you try to hide it in main activity?
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
This applied for 4.1 and Higher, see more in Android Developer

Hide Bottom Option Bar in Android

I want to hide Bottom Option Bar in Android. I don't know whether we call it Option Bar it or not.
Please check it out Image below : Tell me if we call it something else. It is in bottom.
Now, I want to hide it. How to do it ?
It's called navigation bar, the reason for it only having the options button is probably because your device has hardware buttons for home and back, that's why it looks like an options button only bar.
Refer to the docs for hiding it, although it will only work for versions supporting it.
For 4.0+
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Categories

Resources