---
title: "Customize annotation creation toolbar in Android PDF viewer | Nutrient"
canonical_url: "https://www.nutrient.io/guides/android/annotations/custom-annotation-editing-controls/"
md_url: "https://www.nutrient.io/guides/android/annotations/custom-annotation-editing-controls.md"
last_updated: "2026-06-09T10:25:14.352Z"
description: "You can control which annotation tools are enabled in the annotation creation toolbar, as well as build your own custom views."
---

# Customizing the annotation creation toolbar in our Android PDF viewer

You can control which annotation tools are enabled in the annotation creation toolbar, as well as build your own custom views and user interfaces for creating and editing annotations. This guide describes the existing Nutrient APIs for accomplishing this.

## Controlling which annotation tools are enabled

You can control which annotation tools are enabled in the annotation creation toolbar via [`#enabledAnnotationTools`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration.activity/-pdf-activity-configuration/-builder/enabled-annotation-tools.html). Passing `null` or an empty list to this method means that all supported annotation tools are enabled. For example:

### KOTLIN

```kotlin

// In this example, you want to enable all annotation tools except the `IMAGE` tool.
val enabledAnnotationTools = AnnotationTool.values().toMutableList()
enabledAnnotationTools.remove(AnnotationTool.IMAGE)

val config =
    PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation tools are enabled.
        // You can selectively enable certain tools by providing them here..enabledAnnotationTools(enabledAnnotationTools).build()

```

### JAVA

```java

// In this example, you want to enable all annotation tools except the `IMAGE` tool.
List<AnnotationTool> enabledAnnotationTools = new ArrayList<>();
enabledAnnotationTools.addAll(Arrays.asList(AnnotationTool.values()));
enabledAnnotationTools.remove(AnnotationTool.IMAGE);

final PdfActivityConfiguration config =
    new PdfActivityConfiguration.Builder(context)
        // By default, all supported annotation tools are enabled.
        // You can selectively enable certain tools by providing them here..enabledAnnotationTools(enabledAnnotationTools).build();

```

Certain [`AnnotationTool`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool/index.html)s are enabled only when their underlying annotation type, [`AnnotationTool#toAnnotationType`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool/to-annotation-type.html), is editable and annotation editing is enabled.

## Entering annotation mode

You can build your own custom views and user interfaces for creating and editing annotations.

The default [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html) comes with an [`AnnotationToolbar`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.toolbar/-annotation-toolbar/index.html) that hosts all the available annotation tools. When a user taps an icon from the toolbar, the activity will enter annotation mode for the tapped tool.

In your code, you can enter annotation mode by calling [`PdfFragment#enterAnnotatingMode`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/enter-annotating-mode.html) with the desired [`AnnotationTool`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool/index.html) value as the argument:

### KOTLIN

```kotlin

// Enters the signature annotation mode. After tapping the document, the user will be asked to enter a signature.
val tool = AnnotationTool.SIGNATURE
pdfFragment.enterAnnotatingMode(tool)

```

### JAVA

```java

// Enters the signature annotation mode. After tapping the document, the user will be asked to enter a signature.
final AnnotationTool tool = AnnotationTool.SIGNATURE;
getPdfFragment().enterAnnotatingMode(tool);

```

Browse the available [`AnnotationTool`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool/index.html) values to see which tools you can use. For example, to select the ink eraser, you can use [`AnnotationTool.ERASER`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool/-e-r-a-s-e-r/index.html).

To leave annotation mode (switching back to the normal viewing mode), you can call [`PdfFragment#exitCurrentlyActiveMode`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/exit-currently-active-mode.html):

### KOTLIN

```kotlin

// Leaves a previously launched annotation mode.
pdfFragment.exitCurrentlyActiveMode()

```

### JAVA

```java

// Leaves a previously launched annotation mode.
getPdfFragment().exitCurrentlyActiveMode();

```

[`PdfFragment#exitCurrentlyActiveMode`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/exit-currently-active-mode.html) can also be used to leave other special modes — for example, text selection.

### Annotation tool variants

Annotation tools can also have specified variants, and this allows you to have the same annotation tools with different presets. Annotation tool variants are defined by the [`AnnotationToolVariant`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool-variant/index.html) class. This class serves as a wrapper around the string that specifies the name of the variant. Keep in mind that the same variant can be bound to multiple annotation tools. So for example, you can have an ink, line, and highlight tool, all in a “yellow” variant.

To initialize the [`AnnotationToolVariant`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool-variant/index.html) object, you can use one of the three static constructors (which one you use depends upon your use case):

- `AnnotationToolVariant.defaultVariant()` will create the default variant used by the framework for most of the tools.

- `AnnotationToolVariant.fromPreset()` allows you to create the variant from the [`AnnotationToolVariant.Preset`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool-variant/-preset/index.html) enum, which specifies variants used by our framework.

- `AnnotationToolVariant.fromName()` creates your custom variant with the specified name.

To start annotation mode with the specified annotation tool variant, use the version of `PdfFragment#enterAnnotatingMode()` that has both the annotation tool and annotation tool variant as parameters, like so:

### KOTLIN

```kotlin

val tool = AnnotationTool.INK
pdfFragment.enterAnnotatingMode(tool, AnnotationToolVariant.fromName("my_red_thin_ink_variant"))

```

### JAVA

```java

final AnnotationTool tool = AnnotationTool.INK;
getPdfFragment().enterAnnotatingMode(tool, AnnotationToolVariant.fromName("my_red_thin_ink_variant"));

```

To synchronize annotation tool variants with the iOS version, there are two exemptions where we start annotation mode with specific variants. One is the Magic Ink tool, which uses `AnnotationTool.MAGIC_INK` with the variant you can get via `AnnotationToolVariant.fromPresets(Preset.MAGIC)`. The other one is the free text callout tool, which uses `AnnotationTool.FREETEXT_CALLOUT` with the variant you can get via `AnnotationToolVariant.fromPresets(Preset.CALLOUT)`.

Our framework comes with the following predefined annotation tool variant presets (specified in the [`AnnotationToolVariant.Preset`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotation-tool-variant/-preset/index.html) enum class):

- `PEN` — Preset for the pen variant of the ink, used with `AnnotationTool.INK` in the framework.

- `HIGHLIGHTER` — Preset for the highlighter variant of the ink, used with `AnnotationTool.INK` in the framework.

- `MAGIC`— Preset for the magic variant, used with `AnnotationTool.MAGIC_INK` in the framework.

- `CALLOUT` — Preset for the callout variant, used with `AnnotationTool.FREETEXT_CALLOUT` in the framework.

- `ARROW` — Preset for the arrow variant, used with `AnnotationTool.LINE` in the framework.

- `DEFAULT` — Preset for all other tools that have no variant specified.

To start one of our tools programmatically, use the `AnnotationToolVariant.fromPreset()` creator — for example:

### KOTLIN

```kotlin

// Start the pen tool.
val tool = AnnotationTool.INK
val toolVariant = AnnotationToolVariant.fromPreset(AnnotationTool.Preset.PEN)
pdfFragment.enterAnnotatingMode(tool, variant)

```

### JAVA

```java

final AnnotationTool tool = AnnotationTool.INK;
final AnnotationToolVariant toolVariant = AnnotationToolVariant.fromPreset(AnnotationTool.Preset.PEN);
getPdfFragment().enterAnnotatingMode(tool, toolVariant);

```

### Mode listeners

If you need more control of the annotation creation mode, you can register an [`OnAnnotatingModeChangeListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.annotations/-on-annotating-mode-change-listener/index.html) on the fragment. Once the creation mode is entered, the listener will be called, giving you access to the [`AnnotatingController`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui.special_mode.controller/-annotating-controller/index.html). The controller object gives you access to all properties of the currently created annotation (color, size, style, etc.):

### KOTLIN

```kotlin

class ExampleActivity : PdfActivity(), OnAnnotatingModeChangeListener {

    //...

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        pdfFragment.addOnAnnotatingModeChangeListener(this)
    }

    override fun onEnterAnnotatingMode(controller: AnnotatingController) {
        controller.color = Color.RED
        controller.thickness = 10
    }

    /**
     * This method is called whenever the current annotation mode is replaced by another one —
     * for example, when subsequently calling `enterAnnotatingMode(...)`.
     */
    override fun onChangeAnnotatingMode(controller: AnnotatingController) = Unit

    /**
     * This is called when the current annotation mode is left —
     * for example, when calling `fragment.exitCurrentlyActiveMode()`.
     */
    override fun onExitAnnotatingMode(controller: AnnotatingController) = Unit
}

```

### JAVA

```java

public class ExampleActivity extends PdfActivity implements OnAnnotatingModeChangeListener {

    //...

    @Override protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getPdfFragment().addOnAnnotatingModeChangeListener(this);
    }

    @Override public void onEnterAnnotatingMode(@NonNull AnnotatingController controller) {
        controller.setColor(Color.RED);
        controller.setThickness(10);
    }

    /**
     * This method is called whenever the current annotation mode is replaced by another one —
     * for example, when subsequently calling `enterAnnotatingMode(...)`.
     */
    @Override public void onChangeAnnotatingMode(@NonNull AnnotatingController controller) {}

    /**
     * This is called when the current annotation mode is left —
     * for example, when calling `fragment.exitCurrentlyActiveMode()`.
     */
    @Override public void onExitAnnotatingMode(@NonNull AnnotatingController controller) {}
}

```
---

## Related pages

- [Using contextual toolbars within PdfFragment](/guides/android/customizing-the-interface/using-toolbars-within-fragment.md)
- [Annotation editing on Android](/guides/android/user-interface/contextual-toolbars/annotation-editing.md)
- [Customizing toolbars in our Android PDF viewer](/guides/android/customizing-the-interface/customizing-the-toolbar.md)
- [Effortlessly customize text selection in Android](/guides/android/user-interface/contextual-toolbars/text-selection.md)
- [Customizing the PDF editing toolbar on Android](/guides/android/features/document-editor.md)

