Search code examples
androidandroid-layoutandroid-9.0-piemulti-windowcustom-application

Is it possible to provide custom dimensions to my android application?


I want my android application to occupy some customized space (like top left corner of the application and device coincide, with the app occupying 1/4 of the width of the device and 3/4 of the height)

So far, I've tried defining the default dimensions in the android manifest file.

I've also tried calling an activity in the free form mode from another activity

        <activity android:name=".MainActivity"
            <layout
                android:defaultHeight="400dp"
                android:defaultWidth="100dp" />
            ...
        </activity>
        <activity android:name=".MainActivity"
            android:resizeableActivity="true"
            android:taskAffinity="">
            ...
        </activity>

        ...

        <activity
            android:name=".FreeFormActivity"
            android:resizeableActivity="true"
            android:launchMode="singleInstance"
            android:taskAffinity="">
            <layout
                android:defaultHeight="500dp"
                android:defaultWidth="750dp"
                android:gravity="top|end"
                android:minWidth="500dp"
                android:minHeight="500dp" />
        </activity>

The expected result is that my activity opens in a window of the size and position defined by the defaultWidth, defaultHeight and gravity.

The actual result is that the activity spans the entire screen. I do not want this to happen.

Are the default heights and widths being overridden by Android when it launches my app? Is it possible to assert these dimensions and gravity?

Thanks in advance

EDIT: I want my application to be visible to the user even if another application is active. I know the developers added multi-window support, but I want the application to be any dimension I want.


Solution

  • Hi you have to define your application as Widget. Refer to this:

    https://developer.android.com/guide/topics/appwidgets