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

The contextual toolbars are customized through the ToolbarCoordinator. The SDK rebuilds the annotation creation toolbar’s items on each entry, so observe the coordinator and filter the item out whenever the bar shows. This example removes the ink highlighter button:

class MyActivity : PdfActivity() {
private var subscription: ToolbarSubscription? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val coordinator = nutrientToolbarCoordinator()
subscription = coordinator.addContextualToolbarChangeListener { state ->
if (state?.kind == ContextualToolbarKind.Annotation &&
state.items.any { it.id == R.id.pspdf__annotation_toolbar_item_ink_highlighter }
) {
coordinator.updateContextualItems { items ->
items.removeAll { it.id == R.id.pspdf__annotation_toolbar_item_ink_highlighter }
}
}
}
}
override fun onDestroy() {
super.onDestroy()
subscription?.close()
}
}

The item IDs follow the pattern R.id.pspdf__annotation_toolbar_item_*. Removing an item this way only hides the button; the tool stays available programmatically. To disable a tool everywhere, including the toolbar, use PdfActivityConfiguration.Builder.enabledAnnotationTools() instead, as described in annotation creation. For the full customization surface, see customizing contextual toolbars.