This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/android/knowledge-base/remove-tool-variant-from-toolbar.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. How to remove a button from toolbars

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

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setOnContextualToolbarLifecycleListener(this)
}
override fun onPrepareContextualToolbar(toolbar: ContextualToolbar<*>) {
if (toolbar is AnnotationToolbar) {
// 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 { it.id == R.id.pspdf__annotation_toolbar_item_ink_highlighter}
if (highlighterItem != null) {
menuItems.remove(highlighterItem)
}
// Replace the menu items.
toolbar.setMenuItems(menuItems)
}
}
override fun onDisplayContextualToolbar(toolbar: ContextualToolbar<*>) {}
override fun onRemoveContextualToolbar(toolbar: ContextualToolbar<*>) {}