Markwon/docs/SpannableTheme.md
Dimitry 6e2dd36e4f
1.0.1 (#14)
* Added retention annotation for Alignment IntDef (#3)

* Task lists (#4)

* Added since annotation to newly added method/classes

* Fixed the indexes bug for margin spans (#6)

* Feature: Revert spans order (#11)

* SpannableBuilder

* Removed nullablity from Markwon class (no null markdown)

* Image sizes via HTML (#13)
2017-11-11 17:41:10 +03:00

3.9 KiB

SpannableTheme

SpannableTheme controls the appearance of rendered markdown. It has pretty reasonable defaults, which are established based on style of a TextView to which it is applied. It has some factory methods:

// creates ready-to-use SpannableThemeObject
SpannableTheme.create(Context);

// can be used to tweak default appearance
SpannableTheme.builderWithDefaults(Context);

// returns empty builder (no default values are set)
SpannableTheme.builder();

// returns a builder that is instantiated with all values from specified SpannableTheme
SpannableTheme.builder(SpannableTheme copyFrom);

SpannableTheme.Builder have these configurations:

public Builder linkColor(@ColorInt int linkColor);

Block

// left margin for: lists & quotes (text is shifted)
public Builder blockMargin(@Dimension int blockMargin);

Quote

// width of quote indication (the `|`)
public Builder blockQuoteWidth(@Dimension int blockQuoteWidth);

// color of `|` quote indication
public Builder blockQuoteColor(@ColorInt int blockQuoteColor);

Lists

// color of list item bullets(●, ○, ■)/numbers
public Builder listItemColor(@ColorInt int listItemColor);

// stroke width for list bullet (2nd level - `○`)
public Builder bulletListItemStrokeWidth(@Dimension int bulletListItemStrokeWidth);

// width of list bullet (●, ○, ■)
public Builder bulletWidth(@Dimension int bulletWidth);

Code

// text color for `code` blocks
public Builder codeTextColor(@ColorInt int codeTextColor);

// background color for `code` blocks
public Builder codeBackgroundColor(@ColorInt int codeBackgroundColor);

// left margin for multiline `code` blocks
public Builder codeMultilineMargin(@Dimension int codeMultilineMargin);

// typeface of `code` block
public Builder codeTypeface(@NonNull Typeface codeTypeface);

// text size for `code` block
public Builder codeTextSize(@Dimension int codeTextSize);

Headings

// height of the `break` line under h1 & h2
public Builder headingBreakHeight(@Dimension int headingBreakHeight);

// color of the `break` line under h1 & h2
public Builder headingBreakColor(@ColorInt int headingBreakColor);

SuperScript & SupScript

// ratio for <sup> & <sub> text size (calculated based on TextView text size)
public Builder scriptTextSizeRatio(@FloatRange(from = .0F, to = Float.MAX_VALUE) float scriptTextSizeRatio);

Thematic break

// the `---` thematic break color
public Builder thematicBreakColor(@ColorInt int thematicBreakColor);

// the `---` thematic break height
public Builder thematicBreakHeight(@Dimension int thematicBreakHeight);

Tables

// padding inside a table cell
public Builder tableCellPadding(@Dimension int tableCellPadding);

// color of table borders
public Builder tableBorderColor(@ColorInt int tableBorderColor);

// the `stroke` width of table border
public Builder tableBorderWidth(@Dimension int tableBorderWidth);

// the background of odd table rows
public Builder tableOddRowBackgroundColor(@ColorInt int tableOddRowBackgroundColor);

Task lists

Task lists are supported but with some limitations. First of all, task list cannot be nested (in a list, quote, etc). By default (if used factory method builderWithDefaults) TaskListDrawable will be used with linkColor as the primary color and windowBackground as the checkMarkColor.

public Builder taskListDrawable(@NonNull Drawable taskListDrawable);

Contents