I display a custom dialog which is shown proper on show. But after that when I press home key and bring the application in background. Next, I again launch the application from task menu but in that case the image is cut from the top.
Proper Dialog 1
Dialog Clipped From Top 2
Can any one help us in identifying why it must be cutting from top.
Appreciate the help.
This is an issue with Kitkat/Lollipop versions I think. It can be fixed with the following code.
// Only for Api >=4.0
// On Kitkat & Lollipop, layout top gets clipped if this code is not there.
if (android.os.Build.VERSION.SDK_INT >= 16) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}
Related
So I am working on an app which has full screen. The code does work excellently. But when I do switch to any other app and come back to it, the navigation bar and status bar both won't hide. This also happens when I take a screenshot.
Here is a preview:
Coming back, here is what I have coded:
private fun funcFullScreen() {
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
}
And I just simply call the function like this funcFullScreen().
What I have tried?
1] androidFocusableInTouchMode="true"
2] I also tried adding onWindowFocusChange thing but that gave me another headache, the navigation bar will appear for a second or two when I switch the activities in my app itself. And fixing that seems difficult, I've already tried every possible solution for that available on the internet.
Any way to solve this? By the I'm fine with either Java or Kotlin, my app is made up from both (some activities in Java while others in Kotlin) and both suffer from this issue.
3] Also tried adding the code in onResume, this works when I switch back from another app but not when I take a screenshot.
So basically I think you are writing this all code in onCreate() method of that activity, When you go to another app, it's activity screen by default show status bar and navigation bar, and you again come back then you don't get a callback in onCreate(), instead, get it in onResume(), So you need to move your code in OnResume() from onCreate() so that it gets called when you come back again to this screen.
My problem is that components inside a ConstraintLayout spill out of the screen. My app has always worked and I have not made changes to these layouts recently. Now, buttons and views are shifted right and down. The constraints on the components act as if the layout was larger. Suddenly, this problem appeared on an S10, an S9 and an A70 without the app having been updated.
Screenchot of the bug
Screenshot of the normal screen
After taking a screenshot, the layout somewhat comes back to its normal state
The play button is supposed to be centered in x and y. The constraint are all at 0 with the parent view. The remove ads button is constrained left and right equally and from the top only. The array of buttons at the bottom are all within a view, which is constrained equally on the left and right and only from the bottom.
One thing that I noticed is that on my S10, the display settings are either 3040x1440 or 2280x1080. I currently have it set to 3040x1440. It seems like the components are shifted right just enough to fit as if they were in the center of the 3040x1440, but we are only seeing the first 2280x1080 pixels of the screen.
This problem also coincides with the fact that the app now appears with the gaming navigation bar at the bottom. I have never seen my app with this navigation bar before. On the three phones that exhibit this problem, the gaming navbar had never appeared before now and the problem started happening as soon as the bar was introduced. I did not have control over this.
One way I am able to come back to my desired normal layout is by quitting the app and coming back to the app through recently opened apps or via the app icon. Then, the layout is normal until I change activity. Then, the next activity is also spilling out.
All the activities in the app are set to "portrait" in the manifest. All my activities use a ConstraintLayout as their main layout, but not all activities experience this problem.
When that bug was first reported, I tried to reproduce it. The only way I was able to reproduce the bug was by having the app open in split-screen, opening a second app, turning the device sideways to landscape mode and then closing the second app by extending my app. The fact that the phone went from landscape to portrait and fullscreen made it exhibit the comportment you see here.
I think this has to do with the gaming navbar being updated because literally nothing changed in the app between yesterday and today and now this problem exists.
What I tried:
I tried to not hide the navbar and not make the app fullscreen by commenting this code:
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
This did not work, the gaming navbar was present and the UI was still spilling out.
Since, the problem seemed to come from the fact tha tthe app thought it was horizontal, I tried adding this to the affected activities:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
This did not work however.
One activity that experiences this bug doesn't have more UI related code than what is shown here, so I don't think the bug is in my code as the app has worked for months.
I have resolved my issue. Somewhat, my app was using a beta version of the ConstraintLayout.
I simply changed my dependencies from:
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
With the most recent version of ConstraintLayout found here, which is:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
I have an app where fragments are switched in and out of the screen using a bottom tab bar. One of those fragments is made full screen using
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
and that is undone when you leave that fragment.
The problem is that when you leave that fragment and switch to another one, the bottom tab bar drops about halfway off the screen, until a touch event is registered, and then it jumps back to where it's supposed to be. It works fine in the full screen fragment, and fine after the touch event, it's just when you switch away from the full screen fragment, it goes about halfway off the screen.
I am not able to post the code as it is proprietary, but if there are any questions, I can do my best to answer them.
I should note that this issue does not happen on Android Q (API 29), regardless of device.
I see in shops now that device (mostly tablets) have the back and menu buttons as part of the actual screen. As I can't afford another device and mine has back and menu buttons not part of the screen, will my app be able to make use of these if it uses the whole screen. I am using
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
to make it full screen.
If these buttons do get lost is there a way of finding this out, so as to put on screen alternatives for such devices. Also note that I am using minSdkVersion="7", meaning I would like it to work on anything from 2.1 upwards.
Menu button was removed in Honeycomb. You can check API version and blindly assume if it is Honeycomb, then Menu button is not there by default (it will be added when using legacy application though). You can check API version that way:
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
// no menu button by default..
}
These control buttons (home, back and recent apps) are always part of the screen, even in full screen (it can be dimmed, but not removed)
EDIT: however on-screen "Menu" key is not present in Honecomb by default, when you launch legacy application that is not build with targetSdk=11 (or above) then Android will show you that button (otherwise user would not be able to use the app fully). In general - if your app does NOT need menu button at all, then set targetSdk to Honeycomb and up. If you need it, set targetSdk to lower value and Android will take care of this case
In my application, I have set it up in the XML so it is in full screen using
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Now this works fine when the app opens, however if while using the app, I use the home button to back out of the app, and then open it again, when it opens, a black navigation bar will appear for a second or two before disappearing. This does not occur if I exit the app using the back button, just the home button.
Does anyone know why this happens? I have tried doing it from code instead using
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
However, what this does is removes the title bar, but the black bar is there at the top, just nothing is in it.
I.e. this bar
I tried combining the code, by putting the full screen line of code in the XML and also adding the code I showed above into the app, but same thing happens. If I back out of the app with home button and enter it again, that black bar will appear for two seconds temporarily pushing the app and its contents down before righting itself again.
How do I go about fixing this? I have been trying loads of different solutions, but nothing seems to work.
Thanks in advance
Seems to a bug with Android OS. Only way to fix it is go to device, settings animation, and disable animations.
try to remove animation by setting->brightness->animation
set no animation there