> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/basic-operations/basics/fragment-config.md).

# Customize the document viewer in Xamarin

Learn how to customize Xamarin.Android's DocumentActivity and PdfViewCtrlTabHostFragment2 using configuration classes for a tailored document viewer experience. Hide UI components, disable functionali

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android.**
{% endhint %}

[DocumentActivity](/xamarin/guides/android/basics/open.md#activity) and [PdfViewCtrlTabHostFragment2](/xamarin/guides/android/basics/open.md#fragment) are highly configurable and can be easily customized using our document viewer configuration classes. UI components can be hidden and functionality can be disabled by initializing the document viewer using [`ViewerConfig.Builder`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.ViewerConfig.Builder.html).

For further customization, [`PDFViewCtrlConfig`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.PDFViewCtrlConfig.html) allows you to initialize [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html) with low-level viewer settings, and [`ToolManagerBuilder`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.ToolManagerBuilder.html) allows you to customize annotation functionality in [`ToolManager`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Tools.ToolManager.html).

## Configure Document Viewer

`DocumentActivity` and `PdfViewCtrlTabHostFragment2` can be initialized using `ViewerConfig`, which can be created with a `ViewerConfig.Builder` object.

**For example:**

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Customize settings in ViewerConfig
var config = new ViewerConfig.Builder()
    .FullscreenModeEnabled(true)
    .MultiTabEnabled(true)
    .DocumentEditingEnabled(true)
    .LongPressQuickMenuEnabled(true)
    .ShowPageNumberIndicator(true)
    .ShowBottomNavBar(true)
    .ShowThumbnailView(true)
    .ShowBookmarksView(true)
    .ToolbarTitle("My Reader")
    .ShowSearchView(true)
    .ShowShareOption(true)
    .ShowDocumentSettingsOption(true)
    .ShowAnnotationToolbarOption(true)
    .ShowOpenFileOption(true)
    .ShowOpenUrlOption(true)
    .ShowEditPagesOption(true)
    .ShowPrintOption(true)
    .ShowCloseTabOption(true)
    .ShowAnnotationsList(true)
    .ShowOutlineList(true)
    .ShowUserBookmarksList(true)
    .Build();
    
// Initialize your document viewer with a 
// a ViewerConfig when you open a document
DocumentActivity.OpenDocument(context, localFilePath, config)
```

{% endcode %}
{% endtab %}
{% endtabs %}

A full list of settings for `ViewerConfig.Builder` can be found in the [API documentation](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.ViewerConfig.Builder.html).

## Configure PDFViewCtrl

[`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html) specific functionality can be configured using [`PDFViewCtrlConfig`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.PDFViewCtrlConfig.html). You can then pass the configuration to `ViewerConfig` to initialize `PDFViewCtrl` in your document viewer with your specific settings.

**For example:**

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Customize settings in PDFViewCtrlConfig
var pdfViewCtrlConfig = PDFViewCtrlConfig.GetDefaultConfig(this)
    .SetClientBackgroundColor(Android.Graphics.Color.Yellow)
    .SetClientBackgroundColorDark(Android.Graphics.Color.Blue)
    .SetHighlightFields(true)
    .SetImageSmoothing(true)
    .SetUrlExtraction(true)
    .SetMaintainZoomEnabled(true);

// Pass the PDFViewCtrlConfig into your ViewerConfig
// so that it can be used to initialize PDFViewCtrl 
// in your document viewer
var builder = new ViewerConfig.Builder();
var config = builder
    .PdfViewCtrlConfig(pdfViewCtrlConfig)
    // ...
    .Build();
```

{% endcode %}
{% endtab %}
{% endtabs %}

A full list of settings for `PDFViewCtrlConfig` can be found in the [API documentation](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.ViewerConfig.Builder.html).

## Configure ToolManager

Annotation tool functionality can be configured using [`ToolManagerBuilder`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.PDFViewCtrlConfig.html), such as hiding/disabling specific annotation creation tools or disabling the quick menu. You can then pass the configuration to `ViewerConfig` to initialize [`ToolManager`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Tools.ToolManager.html) in your document viewer with your specific settings. Alternatively, you can also modify the style resource for `ToolManager` directly, and pass it to `ViewerConfig`.

* Configure `ToolManager` by setting `ToolManagerBuilder` to an instance of `ViewerConfig`:A full list of settings for `ToolManagerBuilder` can be found in the [API documentation](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Config.ToolManagerBuilder.html).

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Customize settings in ToolManagerBuilder
var toolManagerBuilder = ToolManagerBuilder.From()
    .SetEditFreeTextOnTap(false)
    .SetDisableQuickMenu(true);

// Pass the ToolManagerBuilder into your ViewerConfig
// so that it can be used to initialize ToolManager 
// in your document viewer
var builder = new ViewerConfig.Builder();
var config = builder
    .ToolManagerBuilder(toolManagerBuilder)
    // ...
    .Build();
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Configure `ToolManager` by setting an XML style resource:Defining a style for `ToolManager` is explained in detail in the [ToolManager configuration guide ](/xamarin/annotation/config-annot-tools.md#android).

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Pass the XML style resource R.style.MyToolManager to ViewerConfig
var builder = new ViewerConfig.Builder();
var config = builder
    .ToolManagerBuilderStyleRes(Resource.Style.MyToolManager)
    // ...
    .Build();
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/xamarin/basic-operations/basics/fragment-config.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
