---
title: "Building an activity around the PdfFragment"
canonical_url: "https://www.nutrient.io/guides/android/customizing-the-interface/building-an-activity-around-the-pdffragment/"
md_url: "https://www.nutrient.io/guides/android/customizing-the-interface/building-an-activity-around-the-pdffragment.md"
last_updated: "2026-06-09T10:25:14.352Z"
description: "You might want to customize the user interface of your app beyond what is possible with the predefined UI of the PdfActivity."
---

# Building an activity around the PdfFragment

You might want to customize the user interface of your app beyond what is possible with the predefined UI of the [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html). The greatest flexibility can be achieved by embedding the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) into a custom [`AppCompatActivity`](https://developer.android.com/reference/android/support/v7/app/AppCompatActivity.html). This guide provides the foundation for using the fragment in a custom environment in conjunction with existing Nutrient widgets that are also used by the [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html).

This article describes how to manually build a custom activity that uses the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) and other framework widgets. The other, simpler solutions are to either [extend the existing `PdfActivity`](https://www.nutrient.io/../../customizing-the-interface/extending-pdfactivity) or [load a document into the default `PdfActivity`](https://www.nutrient.io/../../basics/using-activity). You can also use the [`PdfUiFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-ui-fragment/index.html) to display the document with the same UI the [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) uses. To see how, refer to the guide on [how to use a fragment](https://www.nutrient.io/guides/android/basics/using-fragment.md).

## Embedding the fragment

Our [PdfFragment](https://www.nutrient.io/guides/android/basics/using-fragment.md) guide shows the basics of setting up the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) by providing a license and configuration. A runnable code example can be found inside our Catalog app: The `FragmentExample` showcases how to use the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) in a custom [`AppCompatActivity`](https://developer.android.com/reference/android/support/v7/app/AppCompatActivity.html).

## Providing search

Nutrient has two predefined search widgets that are also used by the [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html):

- [`PdfSearchViewInline`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.search/-pdf-search-view-inline/index.html) is a small search widget that, when expanded, sits inside the main action bar. It provides an input field, a results label showing the number of found results, and controls for navigating back and forth inside the results. This widget is useful on smaller devices, where a list of all results would overlay the viewed document.

- [`PdfSearchViewModular`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.search/-pdf-search-view-modular/index.html) is an expandable panel that sits above the document area. It shows a full scrollable list of all results, including preview snippets. Tapping a result will close the search view and navigate to the page containing the result.

As a third option, you can manually build a custom search widget using our [extensive search API](https://www.nutrient.io/guides/android/features/text-search.md).

## Providing toolbars

You can use all the Nutrient toolbars as standalone views in your custom activities. Have a look at the [using toolbars within fragment](https://www.nutrient.io/guides/android/customizing-the-interface/using-toolbars-within-fragment.md) guide for more information.

## Form editing UI

[`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) includes the form editing UI out of the box. Take a look at the [using the form editing UI within fragment](https://www.nutrient.io/guides/android/customizing-the-interface/using-form-ui-within-fragment.md) guide if you want to integrate the form editing UI into your custom activity.
---

## Related pages

- [Extending PdfActivity with custom activities](/guides/android/customizing-the-interface/extending-pdfactivity.md)

