Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Android 7 to create resizable and minimum size activity

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 989
    Comment on it

    Hi, Android 7 i.e nougat supports multi window mode that means at the same time two or more screens can be open like to open email on right side and gallery on left side.

    So to create multi-window screen we have to use a flag in manifest named resizableActivity.

    Resizable activity is one that can resize when using with multi window mode.

    Require jdk : 1.8 or higher

    Require sdk : 24 nougat

    Require dependency :

    compile 'com.android.support:appcompat-v7:24.0.0-beta1'

    Example :

    First of all check in your activity that is device support multi window or not -

    if (!isInMultiWindowMode()) {
        someTextview.setText("Please enable multi window mode.");
    } else {
     someTextview.setText("Multi window mode enabled.");
    }

    declare activity in manifest like this -

    <activity
        android:name="com.android.activities.MyUnresizableActivity"
        android:resizeableActivity="false"
        android:taskAffinity="" />

    and start activity from your main activity file like this :

    Intent intent = new Intent(this, MyUnresizableActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

     

    Now in multi window mode you can also set some activity dimensions and position in the screen, only you have to set layout tag in manifest file like this :

    <activity
        android:name="com.android.multiwindowplayground.MyMinimumSizeActivity"
        android:launchMode="singleInstance"
        android:taskAffinity="">
        <layout
            android:defaultHeight="600dp"
            android:defaultWidth="850dp"
            android:gravity="top|end"
            android:minWidth="600dp"
            android:minHeight="600dp" />
    </activity>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: