Customizing the PDF annotation editing toolbar on Android

When annotations are being edited, Nutrient Android SDK shows the annotation editing toolbar. To use it, select an annotation and the toolbar will be available by default.

Annotation Editing Toolbar

To learn more about customizing the style of the toolbar, refer to our information on toolbar styling.

Entering annotation editing mode

You can build your own custom views and user interfaces for creating and editing annotations.

The class responsible for handling the annotation editing toolbar, its behavior, and its appearance is AnnotationEditingToolbar.java. By default, it comes with PdfActivity.

When a user taps an annotation, the activity will enter the annotation editing mode for the selected annotation.

In your code, you can enter annotation editing modes by calling PdfFragment#enterAnnotationEditingMode with the desired annotation to edit as the argument:

pdfFragment.enterAnnotationEditingMode(annotation)
getPdfFragment().enterAnnotationEditingMode(annotation);

ℹ️ Note: This method won’t select the annotation on the screen. For that, use setSelectedAnnotation(Annotation).

To leave the annotation editing mode (switching back to the normal viewing mode), you can call PdfFragment#exitCurrentlyActiveMode:

// Leaves a previously launched editing mode.
pdfFragment.exitCurrentlyActiveMode()
// Leaves a previously launched editing mode.
getPdfFragment().exitCurrentlyActiveMode()

💡 Tip: PdfFragment#exitCurrentlyActiveMode can also be used to leave other special modes — for example, annotation creation or text selection.

Mode listeners

If you need more control over the annotation editing mode, you can register an OnAnnotationEditingModeChangeListener on the fragment. After entering editing mode, the listener will be called, giving you access to the AnnotationEditingController. The controller object gives you access to all annotation editing mode actions — saving, deleting, toggling the inspector, etc.

Contextual toolbar menu Items

The annotation editing toolbar offers several items for performing operations on a selected annotation. These are outlined below.

Menu item Description
Copy Tapping the Copy menu item will perform a copy to the clipboard of the selected annotation.
Cut Tapping the Cut menu item will perform a cut to the clipboard of the selected annotation.
Color Tapping the colored circle will open the annotation editing inspector.
Undo Tapping the Undo menu item will undo the last action performed.
Redo Tapping the Redo menu item will redo the previously undone action.
Note Tapping the Note menu item will open the annotation note editor.
Delete Tapping the Delete menu item will delete the selected annotation.

Annotation editing inspector

The annotation editing inspector is a Nutrient UI component that allows editing of annotation properties. Once you open it, it’ll slide up from the bottom of the screen. To learn more about the annotation editing inspector, refer to the Annotation Inspector guide.