I am trying to develop an android app which will launch in center of a ChromeBook. But even though I am setting the gravity to center it is always launching in top left corner. But if I set the gravity to any other place rather than center it works fine. For example if I set the gravity to "top|end", it will launch in top right corner.
Here is my Manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:resizeableActivity="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="screenSize|smallestScreenSize|orientation|screenLayout">
<meta-data
android:name="WindowManagerPreference:SuppressWindowControlNavigationButton"
android:value="true" />
<meta-data
android:name="WindowManagerPreference:FreeformWindowSize"
android:value="[tablet]" />
<meta-data
android:name="WindowManagerPreference:FreeformWindowOrientation"
android:value="[landscape]" />
<layout
android:defaultWidth="720dp"
android:defaultHeight="480dp"
android:minWidth="450dp"
android:minHeight="300dp"
android:gravity="center"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here is what worked for me:
<layout>
section entirely (or, optionally, only keep theminWidth
andminHeight
attributes, but drop thedefaultWidth
,defaultHeight
andgravity
).meta-data
values. It should be just: