Hide navigation bar in android tablet with API level 19 and above - hide

My question is in android programming in android studio.
I can hide navigation bar but when dropdown spinner , it show again.
Besides that when i tap on EditText , revealing the softkeyboard will cause the navigation bar to reappear.
how can solve it?
(I searched a lot but could not find the correct answer)
call this method in onCreate , onResume and onWindowFocusChanged
private void hideNavigationBar() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(uiOptions);
}

Related

How to solve the problem that the video is covered by the navigation bar after full screen

like this as follow,When I want to play in full screen, the video is overlaid behind
You have to use this code to hide the navigation bar:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mActivity.getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
//View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
With fullscreen options you can hide status bar too and with Immersive sticky you can get the navigation and status bar again sliding your finger.
To remove this options use the following code:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
View decorView = mActivity.getWindow().getDecorView();
int uiOptions = decorView.getSystemUiVisibility();
uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
uiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
uiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
you can use react-native-full-screen which provide full screen control
You can put that on componentDidmount or useeffect method with FullScreen.onFullScreen();

Hiding the navigation bar in a background service- android

I have an app that introduces a translucent view over all other running apps (basically a filter running as a background service). The problem that i am facing is that the app does not apply the filter over the navigation bar (bottom bar with back, home and recent tabs buttons).
The flags that i have used to create a view are shown in the code below:
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
0 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(mView, params);
Is there any special flag or anything else that i need to cover the nav bar ?
This is the screenshot of the filter running with everything else covered except the nav bar
Add a Y offset to your layoutparams for your overlay to go over your navigation bar.
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,0, navbarHeight(),
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
0 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(mView, params);
private int navbarHeight() {
...code to calculate height of navbar
}

How to create a frame less Dialog box?

My goal is to create a frame-less dialog box using MFC, which are plain rectangle like shown in the image,i have basic knowledge of MFC applications.and dialog box,can you please provide some links for the same.
Copy this code
//Oninitdialog()
LONG lStyle = GetWindowLong(m_hWnd, GWL_STYLE);
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(m_hWnd, GWL_STYLE, lStyle);
Second way
Select you Dialog->properties->Border->None

CEdit in CDockablePane won't scroll

Im using W7, VS2010: create an MDI app with the visual studio look so it has a COutputWnd inherited from CDockablePane at the bottom. Copying the default I've made a new tab, but inherited from CEdit. The tabs inherited from CListBox work great with the following styles:
const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
But the CEdit with the following does not scroll vertically:
const DWORD dwStyle2 = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL;// | ES_READONLY;
I've tried all combinations of the above styles and read tons of websites, but nothing works :(
Oh - and I do have ShowWindow(SW_SHOW);
Thanks for any help you can offer.
Ta-da! Got it sorted. In COutputWnd::OnCreate I had used this as the parent window:
m_wndVehicle->Create(dwStyle2, rectDummy, this, 3);
It should have been &m_wndTabs:
m_wndVehicle->Create(dwStyle2, rectDummy, &m_wndTabs, 3);
Works a treat now!
Hope it saves someone else 2 hours!

uimenucontroller in uiwebview with custom menu items without MORE menu

In my iPad app, there is a UIWebview that displays text content. When I tap hold and select a text, a menu should popup with 2 custom menu.
say, | MENU1 | MENU2 |
But it seems the COPY menu will also accompany, which I couldn't disable. Is there any possibilities to disable it? I tried around the forum and no solutions worked out.
so itz okay to keep the COPY menu along with the other 2. which should now look like
| Copy | MENU1 | MENU2 |
But unfortunately, I 'm getting it displayed with a MORE menu as follows :
| Copy | More... |
Clicking the More... menu is showing the other 2 menu.
But I need all those 2 items to be displayed in the first attempt itself. either just the 2 menus alone, or atleast along with the copy menu.
| Copy | MENU1 | MENU2 |
OR
| MENU1 | MENU2 |
Get me some solution please.... Trying it out in many ways.. But nothing is working out...
Plz help me out...
Thanks,
Brian
It doesn't appear that there is a way to do this without replacing the UIMenuController. One option is to handle your own UILongPressGestureRecognizer (see How to remove th COPY UIMenuItem in UIMenuController). I've seen proposals where you override canPerformAction, but this does not work. Interestingly, the "copy:" action is never called, though it seems that everything else (cut:,select:,etc.) is.
- (BOOL) canPerformAction:(SEL)action withSender:(id)sender
{
if (action == #selector(defineSelection:))
{
return YES;
}
else if (action == #selector(translateSelection:))
{
return YES;
}
else if (action == #selector(copy:))
{
return NO;
}
return [super canPerformAction:action withSender:sender];
}
`

Resources