How to program an app to display in full screen?

  • Replies:6
  • Forum posts: 1

Apr 3, 2022, 7:33:04 PM via Website

Before Android 11, I've adjusted my app to fullscreen easily

My old phone had the camera hole and base buttons outside the screen area, my new phone has a camera hole and the base buttons inside a screen.

With few settings, my app was fullscreen in the old phone.

Styles.xml

<style name="AppTheme.NoActionBar"> <item
 name="windowActionBar">false</item> <item
 name="windowNoTitle">true</item> <item
 name="android:windowFullscreen">true</item> <item
 name="android:windowContentOverlay">@null</item> 
 </style>​

AndroidManifest.xml

<application
...
android:theme="@style/AppTheme.NoActionBar">
</application>

In my new phone with Android 11, I've searched everywhere on Internet. I've tried many different solutions. In the end, I put in my app the following code in that start of OnCreate().

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.attributes.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowCompat.setDecorFitsSystemWindows(window, false)
else {
@Suppress("DEPRECATION")
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}

I wanted a narrow margin near the base buttons and the camera hole, like Chrome.

But all can I get is a wide margin between the app and button (downward) and between the app and the camera hole (upward):

But I would want a narrow margin, similar to Chrome browser for Android:

How can I do this programatically?

I haven't been able to find a single clue to my problem in Internet (and StackOverflow)

I also haven't been able to figure out how to identify if a given cell phone has the camera hole on the screen or if it has the base buttons on the screen. It looks like it's based on DisplayCutout, WindowInsets, boundingRectTop and boundingRectBottom, but there is no real and clear usage example in Internet.

Reply
  • Forum posts: 9

Apr 5, 2022, 12:20:23 PM via Website

Wow, what a detailed report

Helpful?
Reply
  • Forum posts: 1

Jun 26, 2022, 4:38:37 PM via Website

Moving the majority of your code in onCreate to after the setContentView should give you the results your looking for, here is the code I use...

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.R){
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.new_main_menu);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P){
window.getAttributes().layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R){
WindowCompat.setDecorFitsSystemWindows(window,false);
}
}

Helpful?
Reply
  • Forum posts: 38

Jun 28, 2022, 11:37:47 AM via Website

Knowing there’s strong demand is great https://mlsdev.com , but what about the career path for web developers? Most will start out in a junior web development role and eventually work their way up to a senior developer position—but from there it can get interesting. You may eventually manage a team of developers, or you might opt to hone in on a specialized area of web development. Experienced developers could also try their hand at freelancing or starting their own business.

— modified on Jun 29, 2022, 12:27:04 PM

Helpful?
Reply
  • Forum posts: 37

Aug 9, 2022, 8:31:03 AM via Website

window_name.attributes('-fullscreen',True)
We will set the parameter ‘-fullscreen’ of attributes() to True for setting size of our window to fullscreen and to False otherwise.

Helpful?
Reply
  • Forum posts: 4

Aug 30, 2022, 11:21:37 AM via Website

To avoid such problems, you need to focus on creating a detailed plan before the actual app development. This ensures that your business application is simple but powerful in use.

Helpful?
Reply
  • Forum posts: 15

Sep 1, 2022, 1:38:02 PM via Website

If you want to develop a full screen apps, you need to have a better framework boy! A good framework like Node JS for development will help you more in creating a shorter program than the one you have shared. If you are confused to program it yourself you can anyway Hire Node JS Developers even on hourly basis for short duration ! Longer codes have more Time Lag and Loop Process Time which hinder your app performance! pro tip: Shorter the code efficient the App!

Helpful?
Reply