In the TabHostListener there is function you can override called onToolbarOptionsItemSelected
Please see the example code below for a highlight tool
override fun onToolbarOptionsItemSelected(item: MenuItem?): Boolean {
if (item?.itemId == 101) { //101 is your custom button id
val toolManager = mPdfViewCtrlTabHostFragment.currentPdfViewCtrlFragment.toolManager
val tool = toolManager!!.createTool(ToolManager.ToolMode.TEXT_HIGHLIGHT, null)
(tool as Tool).isForceSameNextToolMode = true
toolManager.tool = tool
return true
}
return false
}
Your AnnotationToolbarBuilder would look something like this
We also have sample projects that go into more detail on adding custom tools and buttons. These example can be found here and a more specific example for this scenario can be found here
Can we replace our own icon instead of default ?
E.g. - we are using this line
.addToolButton(ToolbarButtonType.FREE_HIGHLIGHT,DefaultToolbars.ButtonId.FREE_HIGHLIGHT.value())
It give us default icon of HIGHLIGHT , so can we replace this icon with own icon ?
Yes, to replace any resources, you can place a new icon with the same name that is in the library in your application’s “res/drawable” folder, in this case, you’ll want to have your icon as vector drawable, and have the file name as “ic_annotation_free_highlight_black_24dp”. So in your application, you should have “res/drawable/ic_annotation_free_highlight_black_24dp.xml” that is your new icon. Could you please give it a try? Thanks.
FYI - it is possible to find names of existing resources in our download package: Apryse Developer Portal