How to Remove a Button from Toolbars

You can edit PSPDFKit’s toolbars before they’re displayed onscreen. This example shows how to remove the ink highlighter button from the annotation creation toolbar:

override fun onCreate(savedInstanceState: Bundle?) {

override fun onPrepareContextualToolbar(toolbar: ContextualToolbar<*>) {
    if (toolbar is AnnotationCreationToolbar) {
        // Get the existing menu items so you can modify them.
        val menuItems = toolbar.menuItems

        // Find and remove the ink highlighter button from the toolbar.
        val highlighterItem = menuItems.find { ==}
        if (highlighterItem != null) {

        // Replace the menu items.

override fun onDisplayContextualToolbar(toolbar: ContextualToolbar<*>) {}
override fun onRemoveContextualToolbar(toolbar: ContextualToolbar<*>) {}