Completely Transparent Status Bar doesn't work on some devices - android

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

Related

Layout shrinks content when showing Snackbar

I'm using a Unity/Vuforia view in an app, when showing a native Snackbar the whole content shrinks for a bit and stays that way.
My first thought was that it had something to do with the fact that unity/Vuforia sets the activity as 'Fullscreen', disabling that did not work as the issue still remains.
The Content before the snackbar has been shown
After the snackbar
I noticed it has the same height of a Toolbar or the NavigationBars at the bottom. When playing around with the options to hide the Navigation Bars I noticed the changes won't stay. When trying to hide it all, it hides for a second and then after a 200 milliseconds show again.
I tried it with this code
window.decorView.apply {
// 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.
systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
}
The way I fixed it was by enabling the Fullscreen option in Vuforia, it was not what we desired, but it was the quickest solution.

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

Android status bar background disappears when going fullscreen

In my android app I have the status bar overlaying on top of the application content. Whenever I go into fullscreen the status bar instantly changes from its current color to translucent and then the status bar icons animate off the screen. I would like to prevent the status bar from going translucent and instead just keep the same color and animate off screen with the icons.
Here's the code I'm using to go fullscreen:
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
getWindow().getDecorView().setSystemUiVisibility(flags);
This issue only seems to happen on lollipop themes. If I switch from the Material theme to a Holo theme, the status bar animates properly.
Anyone else experience this?
I was able to have a translucent status bar when I go into fullscreen by setting flag_translucent_status. The documentation says it should not be set if you have FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS when trying to set the status bar color. Not a perfect solution and setting this flag also sets SYSTEM_UI_FLAG_LAYOUT_STABLE and SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_TRANSLUCENT_STATUS

Android Navigation Bar overlaying my view

I have an issue with Android Navigation Bar on devices like Nexus etc. Simply at all devices, which do not have the hardware menu button.
Let me explain the issue in more details.
I have an application where there are 3 parts. Content, ActionBar and bottom panel with a SeekBar.
ActionBar and bottom panel with a SeekBar are overlaying the content. Everytime I click on the content the ActionBar and bottom panel with a SeekBar disappear. Which works exactly the way it has to work. Here is a fragment of a code I use for hiding system UI:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
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 | View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
actionBar.hide();
}
findViewById(R.id.read_book_bottom_bar).setVisibility(View.GONE);
In onCreate method of my activity, I have this piece of code:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN);
}
However, when I launch the application on devices with Android Navigation Bar, there is a problem with displaying the bottom panel with a SeekBar. Simply, the Android Navigation Bar overlays the bottom panel with a SeekBar. Here is a screenshot:
But everytime I click on the content, the Android Navigation Bar disappears along with the ActionBar and the bottom panel with the SeekBar. So, the issue is, that everytime somebody would like to use the bottom panel with the SeekBar on devices like NEXUS, he/she would not be able to use it, because it's hidden under the Android Navigation Bar.
Could anybody help me with solving this issue? Thank you all in advance.
Finally, I solved it with attribute fitsSystemWindows = true.
That may also happen when you set android:layout_gravity="center" and android:layout_marginTop="30dp"
I fixed similar issue by seting android:layout_gravity="center_horizontal" instead. Then marginTop works as assumed.

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

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.

Categories

Resources