Dual-screen layout libraries

Important

This article describes functionality and guidance that is in public preview and may be substantially modified before it's generally available. Microsoft makes no warranties, express or implied, with respect to the information provided here.

These libraries are built on top of the Surface Duo dual-screen API. They contains a set of views, layouts, helper functions, and more to help Android developers create applications for dual-screen devices.

When you leave the responsibility of creating and handling all the screen modes to our components, your main focus will be creating your amazing app.

Modules:

  • Core - Contains the core classes that are needed by our components to develop for dual-screen devices. You can also utilize these directly in your code.

    • Use ScreenHelper to get different screen information depending on the screen mode.
    • SurfaceDuoScreenManager provides the possibility to add Listeners to ScreenMode changes.
  • Bottom navigation - Contains a custom BottomNavigationView with dual-screen behavior.

    • SurfaceDuoBottomNavigationView gives the ability to move the BottomNavigationView on the left or right screen.
  • FragmentsHandler - Contains code to handle Fragments in different screen modes.

    • FragmentManagerStateHandler has the ability to restore screen-mode-specific fragments when an activity is transitioning to a dual or single screen.
  • Layouts - Contains the layouts that help you create UI for dual-screen devices.

    • The SurfaceDuoLayout will create SingleScreen or DualScreen containers to hold your UI.
    • SurfaceDuoFrameLayout has the ability to span child views or move them to left or right screen.
  • Tabs - Contains a custom TabLayout class with dual-screen behavior.

    • SurfaceDuoTabLayout has the ability to move the tabs to left screen, right screen, or span to both screens.

Declaring dependencies

Important

Our initial release of these layouts was packaged in a single library com.microsoft.device:dualscreen-layout.

This library will be deprecated. We recommend using the individual libraries for the controls you need.

  1. Add the maven repository url to the top-level build.gradle file:

    allprojects {
       repositories {
           maven {
               url "https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1"
           }
       }
    }
    
  2. Add the dependencies you need to the module-level build.gradle file (you should always include the core library):

    Core

    implementation "com.microsoft.device.dualscreen:core:1.0.0-alpha01"
    

    Bottom navigation

    implementation "com.microsoft.device.dualscreen:bottomnavigation:1.0.0-alpha03"
    

    Fragments handler

    implementation "com.microsoft.device.dualscreen:fragmentshandler:1.0.0-alpha02"
    

    Layouts

    implementation "com.microsoft.device.dualscreen:layouts:1.0.0-alpha02"
    

    Tabs

    implementation "com.microsoft.device.dualscreen:tabs:1.0.0-alpha04"