---
title: "Dynamic layout changes for Android screens"
canonical_url: "https://www.nutrient.io/guides/android/knowledge-base/dynamic-page-layout-when-changing-orientation/"
md_url: "https://www.nutrient.io/guides/android/knowledge-base/dynamic-page-layout-when-changing-orientation.md"
last_updated: "2026-05-15T19:10:04.908Z"
description: "Learn how to adjust your Android app's page layout dynamically when changing screen orientations for optimal viewing."
---

# Change page layout dynamically based on orientation

If you want to display pages in double-page mode in landscape mode and single-page mode in portrait mode, you can do so with the following snippet:

### DYNAMICPAGELAYOUTACTIVITY.KT

```kt

class DynamicPageLayoutActivity : PdfActivity() {

    override fun onCreate(savedInstanceState: Bundle) {
        val isLandscape = resources.configuration.orientation == ORIENTATION_LANDSCAPE
        val pageLayoutMode = if (isLandscape) PageLayoutMode.DOUBLE else PageLayoutMode.SINGLE
        val newConfiguration = PdfActivityConfiguration.Builder(configuration).layoutMode(pageLayoutMode).build()

        configuration = newConfiguration

        // Make sure to call super on the parent `PdfActivity`.
        super.onCreate(savedInstanceState)
    }
}

```

### DYNAMICPAGELAYOUTACTIVITY.JAVA

```java

public class DynamicPageLayoutActivity extends PdfActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        boolean isLandscape = getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE;
        PageLayoutMode pageLayoutMode = isLandscape? PageLayoutMode.DOUBLE : PageLayoutMode.SINGLE;
        PdfActivityConfigurations newConfiguration = new PdfActivityConfiguration.Builder(configuration).layoutMode(pageLayoutMode).build()

        // Set the new configuration.
        setConfiguration(newConfiguration);

        // Make sure to call super on the parent `PdfActivity`.
        super.onCreate(savedInstanceState);
    }
}

```

Note that the [`PageLayoutMode#AUTO`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration.page/-page-layout-mode/index.html) setting leads to similar behavior, where double-page mode is enabled in landscape mode, but only for devices with a screen width larger than 540dp (e.g. tablets).
---

## Related pages

- [Allow Clear Text Traffic](/guides/android/knowledge-base/allow-clear-text-traffic.md)
- [Compose Qna](/guides/android/knowledge-base/compose-qna.md)
- [Disabling Annotation Rotation](/guides/android/knowledge-base/disabling-annotation-rotation.md)
- [Custom Print Functionality](/guides/android/knowledge-base/custom-print-functionality.md)
- [Deleting Pages From A Pdf](/guides/android/knowledge-base/deleting-pages-from-a-pdf.md)
- [Easily disable share and print options in Android](/guides/android/knowledge-base/disable-share-documentinfo-print.md)
- [Managing touch scrolling in Compose containers](/guides/android/knowledge-base/document-view-inside-pager-scroll-handling.md)
- [Getting All Digital Signatures](/guides/android/knowledge-base/getting-all-digital-signatures.md)
- [Getting Signature Location](/guides/android/knowledge-base/getting-signature-location.md)
- [Invoke Search Programmatically](/guides/android/knowledge-base/invoke-search-programmatically.md)
- [Install Failed Insufficient Storage](/guides/android/knowledge-base/install-failed-insufficient-storage.md)
- [Intercepting Touch Events](/guides/android/knowledge-base/intercepting-touch-events.md)
- [Creating invisible digital signatures in Android](/guides/android/knowledge-base/invisible-signature.md)
- [Invoking Share Action Programmatically](/guides/android/knowledge-base/invoking-share-action-programmatically.md)
- [Making Form Elements Read Only](/guides/android/knowledge-base/making-form-elements-read-only.md)
- [Override Hyperlink Behavior](/guides/android/knowledge-base/override-hyperlink-behavior.md)
- [Runtime Permissions Cordova](/guides/android/knowledge-base/runtime-permissions-cordova.md)
- [Remove Tool Variant From Toolbar](/guides/android/knowledge-base/remove-tool-variant-from-toolbar.md)
- [Customize the overflow button color in Android](/guides/android/knowledge-base/styling-overflow-button.md)
- [Save signed PDFs directly to a remote server on Android](/guides/android/knowledge-base/save-signed-pdfs-to-remote-server.md)
- [Using Pspdfkit With Dynamic Feature Modules](/guides/android/knowledge-base/using-pspdfkit-with-dynamic-feature-modules.md)

