Class PopupToolbar

  • All Implemented Interfaces:

    public class PopupToolbar

    A class used for displaying a toolbar as a popup. It's a remake of a default Android text selection toolbar, where the items are displayed horizontally, with overflow button if there are items that don't fit the screen. Then once the overflow button is pressed, the toolbar displays other items vertically, with back button on the bottom to return to the main items.

    • Constructor Detail

      • PopupToolbar

        PopupToolbar(PdfFragment pdfFragment)
        Creates a popup toolbar on the given PdfFragment.
        pdfFragment - PDF fragment for which to create the popup toolbar.
    • Method Detail

      • getViewId

        @IdRes() int getViewId()

        Returns the id of the content view for this toolbar.


        Toolbar's content view ID.

      • setMenuItems

         void setMenuItems(@NonNull() List<PopupToolbarMenuItem> popupToolbarMenuItems)

        Sets menu items to be displayed in this popup toolbar.

        popupToolbarMenuItems - List of menu items to display in the toolbar.
      • getMenuItems

        @NonNull() List<PopupToolbarMenuItem> getMenuItems()

        Gets menu items currently displayed in this popup toolbar.


        List of menu items to display in the toolbar. The items will be displayed as ordered in the list.

      • showAgain

         void showAgain()

        Show the popup toolbar with the parameters that were last used when calling show. This is useful after dismiss was called to temporarily hide the toolbar. If show was never used before, this defaults to pageIndex0 and coordinates 0,0.

      • show

         void show(int pageIndex, float x, float y)

        Show the popup toolbar at the specified page index with possible X and Y offsets. Leaving offset parameters at 0, the toolbar will be displayed so that its center matched the given coordinate horizontally, and that bottom of the toolbar matches the coordinate vertically. Noticeably, all offsets are represented in PDF values.

        pageIndex - Index of the page on which to show the toolbar.
        x - X offset for the toolbar position (in PDF points).
        y - Y offset for the toolbar position (in PDF points).
      • isShowing

         boolean isShowing()

        Gets whether the popup toolbar is currently showing or not.


        true if the toolbar is showing, false otherwise.

      • dismiss

         void dismiss()

        Hides/dismisses the popup toolbar.

      • onItemClicked

         boolean onItemClicked(@NonNull() PopupToolbarMenuItem popupToolbarMenuItem)

        Called when the menu item has been clicked. When overriding this method, make sure you call `super()` so that the OnPopupToolbarItemClickedListener is invoked correctly.

        popupToolbarMenuItem - Item that was clicked.

        true to interrupt the callback, false to let it go through and allow the default menu item click handling.