Configuring scroll directions and page transitions in our Android viewer

Nutrient offers many ways to present your documents, and this guide will provide an overview of the available options. You can configure the page transition, scroll direction, and scroll mode in PdfConfiguration. You can also configure them inside the PdfActivity using the SettingsModePicker.

You need to be aware of the following constraints when using these PdfConfiguration properties (scrollMode, scrollDirection, and layoutMode) simultaneously.

PageScrollMode#PER_PAGE

If the scroll mode is PageScrollMode#PER_PAGE, there are no constraints:

  • The scrollDirection property can be either PageScrollDirection#HORIZTONTAL or PageScrollDirection#VERTICAL.

  • The layoutMode property can be PageLayoutMode#SINGLE, PageLayoutMode#DOUBLE, or PageLayoutMode#AUTO.

val configuration = PdfActivityConfiguration.Builder(context)
    .scrollMode(PageScrollMode.PER_PAGE)
    .scrollDirection(PageScrollDirection.VERTICAL) // Can also be `HORIZONTAL`.
    .layoutMode(PageLayoutMode.SINGLE) // Can also be `DOUBLE`, or `AUTO`.
    .build()
PdfActivityConfiguration configuration = new PdfActivityConfiguration.Builder(context)
    .scrollMode(PageScrollMode.PER_PAGE)
    .scrollDirection(PageScrollDirection.VERTICAL) // Can also be `HORIZONTAL`.
    .layoutMode(PageLayoutMode.SINGLE) // Can also be `DOUBLE`, or `AUTO`.
    .build();

PageScrollMode#CONTINUOUS

If the scroll mode is PageScrollMode#CONTINUOUS:

  • The scrollDirection property can be either PageScrollDirection#HORIZONTAL or PageScrollDirection#VERTICAL.

  • The layoutMode property can only be PageLayoutMode#SINGLE; setting other values has no effect and will default to PageLayoutMode#SINGLE.

val configuration = PdfActivityConfiguration.Builder(context)
    .scrollMode(PageScrollMode.CONTINUOUS)
    .scrollDirection(PageScrollDirection.VERTICAL) // Can also be `HORIZONTAL`.
    .layoutMode(PageLayoutMode.SINGLE) // This will always be forced to `SINGLE`.
    .build()
PdfActivityConfiguration configuration = new PdfActivityConfiguration.Builder(context)
    .scrollMode(PageScrollMode.CONTINUOUS)
    .scrollDirection(PageScrollDirection.VERTICAL) // Can also be `HORIZONTAL`.
    .layoutMode(PageLayoutMode.SINGLE) // This will always be forced to `SINGLE`.
    .build();

Disabling scrolling

If you want to disable scrolling and zooming while keeping everything else (including the thumbnail bar and all toolbar items) enabled, you can call PdfActivity#setDocumentInteractionEnabled(false). Keep in mind that the user will still be able to change the current page using the thumbnail bar.