Some test text!
Android / Guides / Default style properties
These default properties can be changed programmatically and will take effect the next time when the annotation is created.
For example, to change style properties of a rectangle:
RectCreate tool = (RectCreate) toolManager.createTool(ToolManager.ToolMode.RECT_CREATE, null);
tool.setupAnnotProperty(
Color.GREEN,
ToolStyleConfig.getInstance().getCustomOpacity(pdfViewCtrl.getContext(), Annot.e_Square, ""),
ToolStyleConfig.getInstance().getCustomThickness(pdfViewCtrl.getContext(), Annot.e_Square, ""),
Color.RED,
null,
null
);where toolManager is an instance of ToolManager.
A table for annotation type and tool mode mapping can be found here: annotation and its creation tool.
Each annotation has a default style that is defined by its creation tool. For example, when you create a Square annotation using the RectCreate tool for the first time, the default behavior to draw a rectangle with a red border and a transparent fill color. These default colors can changed through XML attributes.
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><div class='info'>
<div class='body'>The first parameter of addDefaultStyleMap is an annotation type. You can determine the annotation type from the creator tool by referring to the <a href="@@tools.tool-manager-android.annot-list">Table of annotations and its creation tool</a>.</div>
</div>
```java
//@data {"m":true}//
// 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);
```
You can also override existing tool's default styles:
| Tool | Style attribute resource | Default style resource |
|---|---|---|
| TextHighlightCreate | R.attr.highlight_default_style | R.style.HighlightPresetStyle1 |
| TextUnderlineCreate | R.attr.underline_default_style | R.style.TextMarkupStyle1 |
| TextStrikeoutCreate | R.attr.strikeout_default_style | R.style.TextMarkupStyle1 |
| TextSquigglyCreate | R.attr.squiggly_default_style | R.style.TextMarkupStyle1 |
| RectLinkCreate | R.attr.link_default_style | R.style.TextMarkupStyle1 |
| RulerCreate | R.attr.ruler_default_style | R.style.RulerStyle1 |
| FreeTextCreate | R.attr.free_text_default_style | R.style.FreeTextPresetStyle1 |
| StickyNoteCreate | R.attr.sticky_note_default_style | R.style.AnnotPresetStyle1 |
| Signature | R.attr.signature_default_style | R.style.SignaturePresetStyle1 |
| FreehandCreate | R.attr.freehand_default_style | R.style.AnnotPresetStyle4 |
| Other | R.attr.other_default_style | R.style.AnnotPresetStyle4 |
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>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="PDFTronAppTheme" parent="PDFTronAppThemeBase">
<item name="freehand_default_style">@style/CustomizedToolStyle</item>
</style>####annot_color
Annotation color. For annotations that have an annot_fill_color, it represents stroke color.
format: color
####annot_text_color
Annotation text color. Used for FreeText annotations.
format: color
annot_fill_colorAnnotation fill color. Used for annotations that have fill colors, including Square, Circle, and FreeText.
format: color
annot_font_sizeAnnotation font size. Used for FreeText annotations.
format: float
annot_text_size_maxRepresents a FreeText annotation's maximum font size.
format: float
annot_text_size_minRepresents a FreeText annotation's minimum font size.
format: float
annot_thicknessAnnotation thickness for border style
format: float
annot_thickness_maxAnnotation maximum thickness
format: float
annot_thickness_minAnnotation minimum thickness
format: float
annot_fontAnnotation font. Used for FreeText annotations.
format: string
annot_opacityAnnotation opacity
format: float
annot_iconAnnotation icon. Used for Text annotations.
format: string
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales