My app is set to be fullscreen and immersive mode so the Status bar and Navigation bar are hidden. I wrote a custom spinner to be able to prevent the navigation bar from appearing when the spinner is clicked. This actually works but the main Activity view still gets resized as if the navigation and status bar has shown. The area where they would normally be displayed is just white. It will stay like this until I click something in the spinner or cancel by clicking outside of the spinner. Is there something I can call on the main view to refresh it's layout to remove the white space or prevent it entirely?
When the Activity is loaded I call my hideSystemUI method:
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Custom spinner onClickListener resets the view back to the original UI layout. So I do not see the actual navigation bars or status bars, just the white space they would have occupied.
Any ideas?
Thanks!
Related
I have two activities: HomePage and MyFavorites. Both have recycler views with items (similar to facebook posts) each item has a button, when you click on it, the item will be shown in the recycler view for MyFav activity. The code for when the button is clicked is in the Adapter class for the recycler view (both activities use the same adapter). Now when a user click on the button for the second time (while the user is in MyFav activity) it means that this specific item should be removed from the recycler view in MyFav activity, but when the button is clicked for a second time while the user is using/opening the HomePage activity the item shouldn’t be removed, the button will turn from red to white ONLY . How can i remove the item only from the recycler view in MyFav activity without removing it from the HomePage activity (since both use the same adapter for their recycler view) without making a new adapter?
If i create separate adapter class for each activity, is it good practice? Since the same code will be duplicated twice with minor changes.
Note: the button (Fav button) is a checkbox with a heart shaped icon, the color is initially white, it will turn red when clicked for the first time, and white when clicked again and so on..
I'm trying to create an immersive full screen app. The issue is, when I type something in an edit text and hide the keyboard, a black navigation bar shows up at the bottom of my app permanently. This ends up blocking my elements from view and making my app look awful in general.
I've tried searching for a solution but nothing I find seems to work or I'm possibly not searching for the correct term. I'd prefer if the only type of navigation that showed was overlaid on a swipe up gesture on top of the app instead of becoming part of my app. The code below works great initially to create the full screen immersion I'm looking for but as soon as an EditText is triggered it basically disables.
private void hideSystemUI(){
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().hide();
getWindow().getDecorView().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);
}
Navigationbar not showing upon the custom action bar what should i do in android
(https://i.stack.imgur.com/MDRCw.png)
I am looking to hide the Sherlock action bar on single tap and show it when user does another single tap thus showing/hiding on alternating single tap.
The code for showing and hiding is:
#Override
public boolean onSingleTapConfirmed(MotionEvent e) {
ActionBar actionBar = getSupportActionBar();
if (actionBar.isShowing()) {
actionBar.hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
} else {
actionBar.show();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
return super.onSingleTapConfirmed(e);
}
The above code works fine for me but the problem is the jerk seen by the user when the transition od action and notification bars occurs from shown to hidden and vice versa.
To avoid the jerk, I added the following line in the onCreate method, but it causes the action bar to cover the UI elements when the action bar comes to visible from invisible state.
requestWindowFeature(com.actionbarsherlock.view.Window.FEATURE_ACTION_BAR_OVERLAY);
Is there any way out by which the jerk is also not there and the action bar is not overlayed on the UI elements when it comes from hidden to visible state?
How about achieving the similar behavior with a sliding menu from top?
you could set roatation to SlidingDrawer and use it
android:rotation="180" // in SlidingDrawer manifest tag.
I understand that SlidingDrawer is deprecated in API 17 but you could always have a custom implementation of this. I'm sure this would be a very smooth implementation for you.
I have a video view and i am hiding the navigation bar when video starts playing, but the view is stretched to the empty part created after the hiding the navigation bar. I want to play the video in full screen behind the navigation bar. So that when i do hide/show navigation bar the stretching and shrinking of video view should be avoided. Any suggestions are appreciated ...
Thanks.
What is it basicallly your navigation bar is it a Preloader,..?
for preloader
you can dismiss it like
pd.dismiss();
use full screen window with flag SYSTEM_UI_FLAG_HIDE_NAVIGATION :
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
reference:
http://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_HIDE_NAVIGATION