Show or hide the UI in our Android viewer
When using PdfActivity, you might want to tweak how Nutrient Android SDK handles its user interface visibility (e.g. toolbars, thumbnail bar). This can be configured by setting setUserInterfaceViewMode in PdfActivityConfiguration.Builder.
Nutrient Android SDK supports the following user interface view modes:
USER_INTERFACE_VIEW_MODE_AUTOMATICtoggles the UI when clicking on the empty page and hides the UI when changing pages. This is the default.USER_INTERFACE_VIEW_MODE_AUTOMATIC_BORDER_PAGESworks the same, but it also shows the UI on the first and last page.USER_INTERFACE_VIEW_MODE_VISIBLEmakes the UI always visible.USER_INTERFACE_VIEW_MODE_HIDDENmakes the UI always invisible.USER_INTERFACE_VIEW_MODE_MANUALdisables any automatic UI controls.
Use USER_INTERFACE_VIEW_MODE_VISIBLE when the toolbar and thumbnail bar should stay visible through taps and page changes. Use USER_INTERFACE_VIEW_MODE_MANUAL when your app owns all show and hide decisions. In manual mode, Nutrient Android SDK won’t toggle the UI automatically, so call setUserInterfaceVisible when your app wants to change the UI state.
User interface view mode can also be changed while PdfActivity is active by calling PdfActivity#setUserInterfaceViewMode.
Manual user interface view mode
If no user interface view mode matches your desired use case, you can control UI visibility manually. Use USER_INTERFACE_VIEW_MODE_MANUAL and call setUserInterfaceVisible to show or hide the UI when required.
For more details, take a look at UserInterfaceViewModesExample in the Catalog app.
Hiding only the main toolbar
The user interface view mode toggles the whole UI: toolbar, thumbnail bar, page number overlay, and navigation buttons. To hide just the main toolbar at runtime, use the host veto on the ToolbarCoordinator. It keeps the toolbar hidden through the SDK’s own visibility changes, such as immersive mode or a contextual toolbar docking on top:
val coordinator = nutrientToolbarCoordinator() // ComponentActivity or Fragment extension.coordinator.setMainToolbarHostVisible(false)// Later: the toolbar returns to whatever the SDK last requested.coordinator.setMainToolbarHostVisible(true)final ToolbarCoordinator coordinator = ActivityToolbarCoordinatorKt.nutrientToolbarCoordinator(this);coordinator.setMainToolbarHostVisible(false);To have no SDK toolbar at all and render your own, set defaultToolbarEnabled(false) in the configuration instead; see the main toolbar guide.
Reacting to user interface visibility changes
If you are providing custom user interface components, you’ll probably want to coordinate visibility of these components with the PdfActivity user interface visibility. Override onUserInterfaceVisibilityChanged to do this. It’s called when the UI visibility changes through either setUserInterfaceVisible or user interaction.
A Compose host, or any code holding the ToolbarCoordinator, can observe the same flag reactively: coordinator.frame is a StateFlow<ToolbarFrame> whose isVisible flips with the user interface, whether or not the SDK renders its own toolbar. The Catalog app’s MainToolbarCustomizationExample animates its own chrome from it.