Some test text!

menu

Customize the viewer's theme

This tutorial only applies to Xamarin.Android.

linkCustomize the viewer's theme

The document viewer can be customized by overriding the CustomAppTheme xml style in your project. For example:

<style name="CustomAppTheme" parent="CustomAppThemeBase">
    <!-- List of required attributes -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="actionMenuTextColor">@color/app_color_icon</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="actionModeBackground">?attr/colorPrimary</item>
    <item name="windowActionModeOverlay">true</item>
</style>

Note that the theme name must either exactly match CustomAppTheme or passed into ViewerBuilder.usingTheme(int) and extend CustomAppThemeBase theme. If you cannot extend CustomAppThemeBase and is extending an AppCompat theme, then you will need to define custom theme attributes for the theme to work properly. Here are the custom attributes:

AttributeDescription
pt_toolbar_themeUsed to style the options menu toolbar. See ToolbarLegacyTheme.
pt_toolbar_popup_themeUsed to style the popup menu in the toolbar. See ToolbarPopupTheme.
pt_toolbar_styleUsed to style the options menu toolbar background. See ToolbarLegacyStyle.
annotation_toolbarused to style the annotation toolbar. See CustomAnnotationToolbarLegacyStyle.
pt_pdf_tab_layout_styleUsed to style the document tabs. See PdfTabLayoutStyle.
pt_stamp_tab_layout_styleUsed to style the stamp dialog tab layout. See StampTabLayoutLegacyStyle.
custom_bookmarks_tab_layoutUsed to style the outline/user bookmark/annotation list dialog. See BookmarksTabLayoutLegacyStyle.
pt_floating_nav_styleUsed to style the floating action buttons. See DefaultFloatingButtonNavLegacyStyle.
pt_sound_dialog_styleUsed to style the sound dialog. See SoundDialogLegacyStyle.

Additionally if you are not using a NoActionBar theme AppCompat theme, you will need to add the additional attributes:

<style name="CustomAppTheme" parent="Theme.AppCompat.*">
    ...
    <!-- Action bar -->
    <item name="windowActionModeOverlay">true</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

linkCustomize a component

Similarly, each component in the viewer can be customized separately depending on your design requirements. To do so, the styles of each component must be referenced in CustomAppTheme. For example:

<style name="CustomAppTheme" parent="CustomAppThemeBase">
    <!-- List of required attributes -->
    <item name="actionMenuTextColor">@color/app_color_icon</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="actionModeBackground">?attr/colorPrimary</item>
    <item name="windowActionModeOverlay">true</item>

    <!-- Custom annotation toolbar style (defined below) -->
    <item name="annotation_toolbar">@style/ToolbarButtonNavigationStyle</item>
</style>

<style name="CustomAnnotationToolbarStyle" parent="AnnotationToolbarStyle">
    <item name="colorToolBackground">@color/annotation_tool_background</item>
    <item name="colorToolIcon">@color/app_color_icon</item>
    <item name="colorCloseIcon">@color/app_color_icon</item>
</style>

linkCustomizable components

For a full list of component styles available, please take a look at the default styles for CustomAppTheme in styles.xml of the Tools package.

A sample that uses styles to customize the document viewer can be found on our GitHub repository.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.