---
title: "Hide or customize scrollbar in Android PDF viewer | Nutrient"
canonical_url: "https://www.nutrient.io/guides/android/customizing-the-interface/scrollbars/"
md_url: "https://www.nutrient.io/guides/android/customizing-the-interface/scrollbars.md"
last_updated: "2026-05-20T19:49:34.727Z"
description: "Nutrient comes with out-of-the-box scrollbars indicating the current scroll position and remaining scroll range (i.e. the remaining pages in the document)."
---

# Hide or customize scrollbars in our Android viewer

Nutrient comes with out-of-the-box scrollbars indicating the current scroll position and remaining scroll range (i.e. the remaining pages in the document). You can change the scrollbar’s default visual appearance, turn scrollbars off if you don’t need them, or replace scrollbars completely with your own custom scrollbar logic using scroll event listeners.

## Disabling scrollbars

By default, the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) shows vertical and horizontal scrollbars. If you are using the [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html), you can disable these scrollbars by setting [`PdfActivityConfiguration.Builder#scrollbarsEnabled`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration.activity/-pdf-activity-configuration/-builder/scrollbars-enabled.html) to `false`:

### KOTLIN

```kotlin

val config = PdfActivityConfiguration.Builder(context).scrollbarsEnabled(false).build()

```

### JAVA

```java

final PdfActivityConfiguration config
    = new PdfActivityConfiguration.Builder(context).scrollbarsEnabled(false).build();

```

If you are using the [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) instead of the activity, you can disable scrollbars using the equivalent method, [`PdfConfiguration.Builder#scrollbarsEnabled`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration/-pdf-configuration/-builder/scrollbars-enabled.html):

### KOTLIN

```kotlin

val config = PdfConfiguration.Builder().scrollbarsEnabled(false).build()

```

### JAVA

```java

final PdfConfiguration config
    = new PdfConfiguration.Builder().scrollbarsEnabled(false).build();

```

## Styling the scrollbars

It’s possible to change the appearance of scrollbars by [using a custom theme](https://www.nutrient.io/guides/android/customizing-the-interface/appearance-styling.md). Set the `pspdf__documentViewStyle` attribute of the theme to a style containing all your desired scrollbar properties. Since Nutrient uses the default scrollbars of the [`View`](https://developer.android.com/reference/android/view/View.html) class, you can use all of the existing scrollbar properties defined by that class:

```xml

<!-- Your custom PSPDFKit theme. -->

<style name="MyApp.Theme" parent="Theme.AppCompat.NoActionBar">
    <item name="pspdf__documentViewStyle">@style/MyApp_DocumentViewStyle</item>
</style>

<!-- Your scrollbar styles can go here. -->

<style name="MyApp_DocumentViewStyle">
    <item name="android:scrollbarSize">6dp</item>
    <item name="android:scrollbarThumbVertical">@color/my_scrollbar_color</item>
    <item name="android:scrollbarThumbHorizontal">@color/my_scrollbar_color</item>
    <item name="android:scrollbarStyle">insideOverlay</item>
    <item name="android:scrollbars">horizontal|vertical</item>
</style>

```

The above scrollbar style only contains a subset of the existing scrollbar properties. For a full list of available style attributes, take a look at the [available `View` attributes in the official Android documentation](https://developer.android.com/reference/android/view/View.html#lattrs). If you are interested in a live example, check out the `DarkThemeExample` inside the Catalog app.

If you are interested in the default scrollbar style, see `@style/PSPDFKit.DocumentView`, which is automatically used by Nutrient if your theme does not define a different style.

## Document scroll listeners

If the default scrollbars don’t provide the features your app requires, you can use a [`DocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/index.html) to observe scrollbar events on [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html). Once you register the listener using [`PdfFragment#addDocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/add-document-scroll-listener.html), it receives all raw scrollbar events for consumption of your own scrollbar code:

### KOTLIN

```kotlin

val myListener: DocumentScrollListener = MyScrollListener()
fragment.addDocumentScrollListener(myListener)

```

### JAVA

```java

final DocumentScrollListener myListener = new MyScrollListener();
fragment.addDocumentScrollListener(myListener);

```

To prevent undesired leaks, the&nbsp;[`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html) removes all registered [`DocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/index.html) instances inside its `#onDetach` method. This means that you need to register your listener every time the fragment is attached to your activity (for example, at activity creation time). You are encouraged to manually unregister the document scroll listener if you no longer need it by using [`PdfFragment#removeDocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/remove-document-scroll-listener.html).

### Scrollbar events

Document scrollbar events consist of three different values. A [`DocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/index.html) will receive those values inside its [`#onDocumentScrolled`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/on-document-scrolled.html) method. For each value, there is an X dimension and a Y dimension, since the document can scroll both vertically and horizontally. The received values are expressed in an arbitrary zero-based unit and should only be treated in relation to each other. The values are:

- Range — The total scrollable range inside the document. Range is expressed by `maxX` and `maxY`.

- Offset — The current scrollbar position, which is always inside the range. Offset is expressed by `currX` and `currY`.

- Extend — The relative size of the scrollbar compared to the total range. Extend is expressed by `extendX` and `extendY`.

### KOTLIN

```kotlin

override fun onDocumentScrolled(fragment: PdfFragment, currX: Int, currY: Int, maxX: Int, maxY: Int, extendX: Int, extendY: Int) {
    // Your custom scrollbar code.
}

```

### JAVA

```java

@Override
public void onDocumentScrolled(@NonNull PdfFragment fragment, int currX, int currY, int maxX, int maxY, int extendX, int extendY) {
    // Your custom scrollbar code.
}

```

The current document scrolling state (dragged, settling, idle) is represented by the [`ScrollState`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-scroll-state/index.html) enum type. The [`DocumentScrollListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/index.html) can observe changes of the document scroll state inside its [`#onScrollStateChanged`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners.scrolling/-document-scroll-listener/on-scroll-state-changed.html) method:

### KOTLIN

```kotlin

override fun onScrollStateChanged(fragment: PdfFragment, state: ScrollState) {
    // Consume scroll state changes here.
}

```

### JAVA

```java

@Override
public void onScrollStateChanged(@NonNull PdfFragment fragment, @NonNull ScrollState state) {
    // Consume scroll state changes here.
}

```

If you want to see a live demo of custom scrollbar events, take a look at `VerticalScrollbarExample` inside the Catalog app. It shows how to use the new scroll API together with the [`VerticalScrollBar`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.scrollbar/-vertical-scroll-bar/index.html) widget to allow quick document navigation.
---

## Related pages

- [Customizing the form editing toolbar on Android](/guides/android/customizing-the-interface/using-form-ui-within-fragment.md)
- [Customizing PDF viewer styling on Android](/guides/android/customizing-the-interface/appearance-styling.md)
- [Customizing our PDF viewer on Android](/guides/android/user-interface.md)
- [Customize toolbar menus on Android](/guides/android/customizing-the-interface/customizing-menus.md)
- [Localization: Change languages in our Android PDF viewer](/guides/android/features/localization.md)
- [Customizing dialog modals on Android](/guides/android/customizing-the-interface/modal-dialogs-styling.md)
- [Overlay views on Android](/guides/android/features/overlay-views.md)
- [Separate the document info view in our Android viewer](/guides/android/user-interface/separate-document-info.md)
- [Customizing the note editor on Android](/guides/android/customizing-the-interface/customizing-the-note-editor.md)
- [Show or hide the UI in our Android viewer](/guides/android/customizing-the-interface/user-interface-visibility.md)
- [Customizing the electronic signature UI on Android](/guides/android/customizing-the-interface/configuring-the-signaturepickerfragment.md)
- [Customizing the thumbnail file viewer on Android](/guides/android/customizing-the-interface/customizing-the-thumbnail-bar.md)

