Surface Duo Frame Layout

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.

Important

The content of this view will be available only after the Activity root view is attached to the window. This happens because the implementation is based on Window Manager library and the Window Manager is working only when view is attached to the window.

SurfaceDuoFrameLayout is a FrameLayout that can wrap any Android view and render it on one or both screens. The layout supports only one child.

surfaceDuoDisplayPosition - Returns or sets a value that specifies on which screen the widget will render the child view. Can be one of the three values:

  • DisplayPosition.START - appears on first screen.
  • DisplayPosition.END - appears on second screen.
  • DisplayPosition.DUAL - spanned across both screens (might appear under hinge).

START: tabs on the first screen

DisplayPosition.START

END: tabs on the first screen

DisplayPosition.END

DUAL: tabs on the first screen

DisplayPosition.DUAL

How to change the view's behavior

surfaceDuoFrameLayout.surfaceDuoDisplayPosition = DisplayPosition.START

The same can be obtained using the app:display_position attribute in conjunction with tool:tools_application_mode.

<com.microsoft.device.dualscreen.layouts.SurfaceDuoFrameLayout
    android:id="@+id/duo_wrapper"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:display_position="start"
    tool:tools_application_mode="dual_screen">
    ...
</com.microsoft.device.dualscreen.layouts.SurfaceDuoFrameLayout>