Default annotation propertieskeyboard_arrow_down

Default Annotation Properties

Each annotation has a default style that is defined by the creation tool. For example, when you create a Square annotation using the RectCreate tool, the default behavior is for a rectangle to be drawn with a red border and a transparent fill color. These default colors can be easily overridden.

linkSetting a tool's default style

  1. Add a style to your styles.xml file. For details on supported style attributes, see Tool Style Attributes.
<style name="ShapeProperty">
    <!-- border color -->
    <item name="annot_color">@android:color/white</item>
    <!-- fill color -->
    <item name="annot_fill_color">@android:color/white</item>
    <!-- thickness -->
    <item name="annot_thickness">1.0</item>
    <!-- opacity -->
    <item name="annot_opacity">1.0</item>
</style>
  1. Add the style resource to ToolStyleConfig by calling addDefaultStyleMap(int, int styleRes).
The first parameter of addDefaultStyleMap(int, int styleRes) is an annotation type. You can determine the annotation type from the creator tool by referring to the Table of Annotations and Creator Tools.
// Add the R.style.ShapeProperty to RectCreate tool.
// Since the RectCreate tool creates a Square annotation, the annotation type of a Square
// annotation is Annot.e_Square
ToolStyleConfig.getInstance().addDefaultStyleMap(Annot.e_Square, R.style.ShapeProperty);

linkOverriding an existing tool's default style

You can also override existing tools' default styles:

  1. Identify the tool whose style you want to override by consulting the following table.
ToolStyle attribute resourceDefault style resource
TextHighlightCreateR.attr.highlight_default_styleR.style.HighlightPresetStyle1
TextUnderlineCreateR.attr.underline_default_styleR.style.TextMarkupStyle1
TextStrikeoutCreateR.attr.strikeout_default_styleR.style.TextMarkupStyle1
TextSquigglyCreateR.attr.squiggly_default_styleR.style.TextMarkupStyle1
RectLinkCreateR.attr.link_default_styleR.style.TextMarkupStyle1
FreeTextCreateR.attr.free_text_default_styleR.style.FreeTextPresetStyle1
StickyNoteCreateR.attr.sticky_note_default_styleR.style.AnnotPresetStyle1
SignatureR.attr.signature_default_styleR.style.SignaturePresetStyle1
FreehandCreateR.attr.freehand_default_styleR.style.AnnotPresetStyle4
OtherR.attr.other_default_styleR.style.AnnotPresetStyle4
  1. Create a custom tool style that inherits from the default tool style resource in styles.xml. For example, if you want to override the FreehandCreate tool style, your custom tool style should inherit from AnnotPresetStyle4.
<style name="CustomizedToolStyle" parent="AnnotPresetStyle4">
    <item name="annot_color">@android:color/white</item>
</style>
To learn about style inheritance, see: Defining styles and inheritance.
  1. In your application theme, set your custom tool style (CustomizedToolStyle) to the tool style attribute that corresponds to the tool style you wish to override. For example, if you want to the override FreehandCreate tool style, set CustomizedToolStyle to the attribute freehand_default_style.
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name"freehand_default_style">@style/CustomizedToolStyle</item>
</style>
To learn about applying custom themes to your application, see: Applying a Theme to an Activity or Application.

linkTool style attributes

linkannot_color

Annotation color. For annotations that have an annot_fill_color, it represents stroke color.

format: color

linkannot_text_color

Annotation text color. Used for FreeText annotations.

format: color

linkannot_fill_color

Annotation fill color. Used for annotations that have fill colors, including Square, Circle, and FreeText.

format: color

linkannot_font_size

Annotation font size. Used for FreeText annotations.

format: float

linkannot_text_size_max

Represents a FreeText annotation's maximum font size.

format: float

linkannot_text_size_min

Represents a FreeText annotation's minimum font size.

format: float

linkannot_thickness

Annotation thickness for border style

format: float

linkannot_thickness_max

Annotation maximum thickness

format: float

linkannot_thickness_min

Annotation minimum thickness

format: float

linkannot_font

Annotation font. Used for FreeText annotations.

format: string

linkannot_opacity

Annotation opacity

format: float

linkannot_icon

Annotation icon. Used for Text annotations.

format: string