Elliptica
Elliptica

Reputation: 4332

How to Get Apps to Show Full Screen on Chromebook?

I've been making Android apps for a long time and can get them to open in full screen mode on every device except Chromebook. No matter what I do, they only open about half screen and a user has to click the "maximize" button to get them to open further.

Here is the code I use to try to get the apps full screen:

<item name="android:windowFullscreen">true</item>

in the relevant style in themes.xml

as well as

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

in MainActivity's onCreate() method.

I've also tried putting

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

in the application block of AndroidManifest.xml.

Is there something else I can do to get the apps to open full screen on Chromebook?

(I'm using HP Chromebook x360, if that helps)

Upvotes: 0

Views: 1814

Answers (1)

Morrison Chang
Morrison Chang

Reputation: 12121

So there is a section of the Android documentation for using Android on ChromeOS which makes reference to Window Management - Launch Size which seems appropriate.

Quoting from the documentation:

  • Use a launch size only in desktop environments. This helps the window manager to give you the proper bounds and orientation. To indicate a preferences when used in desktop mode, add the following meta tags inside the <activity>:
<meta-data android:name="WindowManagerPreference:FreeformWindowSize"
       android:value="[phone|tablet|maximize]" />
<meta-data android:name="WindowManagerPreference:FreeformWindowOrientation"
       android:value="[portrait|landscape]" />
  • Use static launch bounds. Use inside the manifest entry of your activity to specify a "fixed" starting size. See this example:
<layout android:defaultHeight="500dp"
        android:defaultWidth="600dp"
        android:gravity="top|end"
        android:minHeight="450dp"
        android:minWidth="300dp" />
  • Use dynamic launch bounds. An activity can create and use ActivityOptions.setLaunchBounds(Rect) when creating a new activity. By specifying an empty rectangle, your app can be maximized.

Note: These options work only if the activity started is a root activity. You can also do this using a springboard activity to clear the activity stack in the task with a new start.

Upvotes: 1

Related Questions