Some test text!

Search
Hamburger Icon

Xamarin / Guides / Quick menu (Android)

Quick Menu

You can use a quick menu in the document viewer.

Annotation popup menu with long-press in Xamarin.Android

This tutorial only applies to Xamarin.Android.

QuickMenu is a convenient annotation popup menu that appears when a user long-presses on a blank space or on text contained in a PDFViewCtrl. It extends RelativeLayout and is a child view of PDFViewCtrl.

ActionMenu
Long-press on blank spacequick menu when long-press on blank space
Long-press on textquick menu when long-press on blank space
To learn more about each icon, see the icon cheat sheet .
To learn how to customize the quick menu, see the customize quick menu guide .

Quick menu events

A number of events may be raised when a user interacts with the quick menu. For example, events will be raised when the quick menu is shown, dismissed, or when a quick menu item is clicked. .

If your activity is using PdfViewCtrlTabHostFragment2 for viewing PDF files, you can set your listener by calling:

mPdfViewCtrlTabHostFragment.CurrentPdfViewCtrlFragment.QuickMenuClicked += (sender, e) =>
{
    // Handle click event...
}

mPdfViewCtrlTabHostFragment.CurrentPdfViewCtrlFragment.QuickMenuShown += (sender, e) =>
{
    // Called when the quick menu is shown
}

mPdfViewCtrlTabHostFragment.CurrentPdfViewCtrlFragment.QuickMenuDismissed += (sender, e) =>
{
    // Called when the quick menu is dismissed
}

Or you can register the listener using the ToolManager:

mToolManager.QuickMenuClicked += (sender, e) =>
{
    // Handle click event...
}

mToolManager.QuickMenuShown += (sender, e) =>
{
    // Called when the quick menu is shown
}

mToolManager.QuickMenuDismissed += (sender, e) =>
{
    // Called when the quick menu is dismissed
}

Hide quick menu items

If there are tools that you would like to remove from the quick menu, you can hide them by calling ToolManager.DisableToolMode:

mToolManager.DisableToolMode(new ToolManager.ToolMode[] {
    ToolManager.ToolMode.TextSquiggly,
    ToolManager.ToolMode.TextStrikeout
});

Then, when you long-press on text you will see:

quick menu image

ToolMode icon mapping table

IconToolMode
Rectangle imageRECT_CREATE
Ellipse imageOVAL_CREATE
Polyline imagePOLYLINE_CREATE
Polygon imagePOLYGON_CREATE
Cloud imageCLOUD_CREATE
Line imageLINE_CREATE
Arrow imageARROW_CREATE
Ruler imageRULER_CREATE
Free text imageTEXT_CREATE
Callout imageCALLOUT_CREATE
Note imageTEXT_ANNOT_CREATE
Ink imageINK_CREATE
Eraser imageINK_ERASER
Signature imageSIGNATURE
Stamp imageSTAMPER
Rubber stamp imageRUBBER_STAMPER
Free highlighter imageFREE_HIGHLIGHTER
Highlight imageTEXT_HIGHLIGHT
Underline imageTEXT_UNDERLINE
Squiggly imageTEXT_SQUIGGLY
Strikeout imageTEXT_STRIKEOUT
Group select imageANNOT_EDIT_RECT_GROUP

Disable quick menu

If you would like to hide the long press quick menu entirely, you can do so by calling ToolManager.SetDisableQuickMenu. For example:

mToolManager.SetDisableQuickMenu(true);

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales