So I have a custom ListPreference that I want to hide the System UI Elements once the dialog box is presented on the screen.
I have found a post about how to hide element inside the dialog box itself (like the cancel button and title), however, I am not quite sure on how to access those particular pieces.
#Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
super.onPrepareDialogBuilder(builder);
//hide System UI elements here
}
This looks like a good place to make the changes to me, however, I am not 100% on it.
View decorView = getWindow().getDecorView();
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_STICKY);
This is how the activities accomplish what I am trying to achieve.
getView() is also what I assume to be an approach to this, however, I am not quite sure if the dialog box is a Fragment or not.
Ok so I am able to hide the UI elements but it seem like there is still some sort of transparent bars left over.
Does anyone know of a way to get rid of these remnant bars?
#Override
protected void showDialog(Bundle state) {
super.showDialog(state);
getDialog().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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
This is how I am getting rid of the System UI Elements.
Related
I am beginner in Android, and I am trying to create a touch blocker app so,
Can we disable the touch sensitivity of the screen by using certain gesture in android using java ,and the sensitivity of the screen should be back to normal with certain gestures in android application using java.
If possible can anyone give bird view of code snippet?
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | 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;
decorView.setSystemUiVisibility(uiOptions);
ConstraintLayout parentLayout = (ConstraintLayout) findViewById(R.id.main_layout);
parentLayout.setClipChildren(true);
myLayout.setEnabled(false);
Hi guys i'm a beginner on android studio,
I noticed that when I run my app on my phone, the status bar and also the on-screen buttons are visible but on my friend's device there is no status bar or on-screen buttons so it uses the full resolution, how can i force the app to have both on all devices? The resolution for my phone and his phone is the same (1080x2340) but on his phone it's like it just zooms out.
Is there a way to set the app to work the same on both devices? I mean, the resolution is the SAME but the app looks different because of status bar/on-screen buttons.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.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);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
I'm adding a view to windows manager using these layout parameters:
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT
);
The expected result is an overlay window that covers the entire screen except the system ui (navigation bar and status bar) and doesn't cover the soft keyboard.
The above parameters do that but the problem is that the navigation bar buttons are not visible while the soft keyboard is open.
Current result:
Expected result:
I've tried a couple of flags like:
WindowManager.LayoutParams.FLAG_LAYOUT_ATTACHED_IN_DECOR
and a combination of:
WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
But none of them worked.
I've also gone through the documentation for system ui but most option there that involve WindowManager.LayoutParams flags are for hiding the decoration and the rest of them require a reference to the window which I don't think I can get from an accessibility service.
The problem seems to be the:
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
flag, if I remove it, the navigation buttons are visible but the overlay will cover the keyboard, it will do that even if I use something like this:
params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
My question:
Is there any way to have an overlay that doesn't cover the keyboard and doesn't hide the navigation bar buttons ?
Did you try switching from PixelFormat.TRANSLUCENT to PixelFormat.TRANSPARENT? Also:
.apply {
gravity = Gravity.BOTTOM //CENTER or whatever
x = 0
y = 0
screenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
I'm using Codename One to develop a mobile app.
I have an outer-Container which I added an ActionListener by invoking the method addPointerReleasedListener to it.
There are more inner-Containers which are NOT added with any listeners.
To illustrate:
outer-Container (added `addPointerReleasedListener` to it)
- An Image Container (NO listener added)
- A Text Container (NO listener added)
--------------------------------------------------------------
| | | |
| | | |
| | Image | Some Text here |
| | | |
| | | |
--------------------------------------------------------------
^ ^ ^
works only if I click/press
here
I noticed that in order to invoke the event, I have to click/press on an area which is not occupied any inner-Containers. That is, it does not work if I click/press on any text and image areas (because there no listeners added to it). I have to specifically click/press on an "empty" area of the outer-Container. Obviously, this does not make sense because I want to make the entire container react the same way when the user clicks/presses anywhere within it.
What is the best method/practice to implement this? (I find it a bit redundant to add the same listener to many inner-Containers.)
Your approach won't work properly on real devices.
Create a button and add your actionListener to it and set your outer container's leadComponent to that button.
Button btn = new Button("");
btn.addActionListener(e -> {
//Your action here
});
outerContainer.setLeadComponent(btn);
You don't have to add that button to your container, just set it as the leadComponent only.
It's late, I'm tired and I can't figure out why a simple popup panel instead of showing as it should, displays a label beneath my. For example:
|SOME CLICKABLE BUTTONS| | |
|SOME MORE OPTIONS | | SOME CONTENT |
|EVEN MORE OPTIONS | | |
|Please wait|
"Please wait" is the label as you can see is created like so in the:
#Override
public void onModuleLoad()
{ ...<snip> //creates
final PopupPanel popup = new PopupPanel(false, true);
popup.add(new Label("Please wait"));
popup.center();
RootPanel.get().add(popup);
Some things you should know:
I'm running this in development mode via Jetty. I'm using reflections without class literals to load my panels because I haven't come round to implementing the workaround using generators (and the application is rather large, so it needs splitting). Though I doubt these things are causing it problems.
Shouldn't upon load, a popup display? My overall goal is to have something which displays a loading gif everytime a new part of the application is loading.
Do not add your PopupPanel to a RootPanel.
Delete this line
RootPanel.get().add(popup);
and it will work.