HtmlCompat
public final class HtmlCompat
Backwards compatible version of Html.
Summary
Constants |
|
|---|---|
static final int |
Flags for |
static final int |
Flags for |
static final int |
Flag indicating that CSS color values should be used instead of those defined in |
static final int |
Flag indicating that texts inside |
static final int |
Flag indicating that texts inside |
static final int |
Flag indicating that texts inside |
static final int |
Flag indicating that texts inside |
static final int |
Flag indicating that texts inside |
static final int |
Flag indicating that texts inside |
static final int |
Option for |
static final int |
Option for |
Public methods |
|
|---|---|
static @NonNull Spanned |
Invokes |
static @NonNull Spanned |
fromHtml(Invokes |
static @NonNull String |
Invokes |
Constants
FROM_HTML_MODE_COMPACT
public static final int FROM_HTML_MODE_COMPACT = 63
Flags for fromHtml: Separate block-level elements with line breaks (single newline character) in between. This inverts the Spanned to HTML string conversion done with the option TO_HTML_PARAGRAPH_LINES_INDIVIDUAL.
FROM_HTML_MODE_LEGACY
public static final int FROM_HTML_MODE_LEGACY = 0
Flags for fromHtml: Separate block-level elements with blank lines (two newline characters) in between. This is the legacy behavior prior to N.
FROM_HTML_OPTION_USE_CSS_COLORS
public static final int FROM_HTML_OPTION_USE_CSS_COLORS = 256
Flag indicating that CSS color values should be used instead of those defined in Color.
FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE = 32
Flag indicating that texts inside <blockquote> elements will be separated from other texts with one newline character by default.
FROM_HTML_SEPARATOR_LINE_BREAK_DIV
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_DIV = 16
Flag indicating that texts inside <div>elements will be separated from other texts with one newline character by default.
FROM_HTML_SEPARATOR_LINE_BREAK_HEADING
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_HEADING = 2
Flag indicating that texts inside <h1>~<h6> elements will be separated from other texts with one newline character by default.
FROM_HTML_SEPARATOR_LINE_BREAK_LIST
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST = 8
Flag indicating that texts inside <ul> elements will be separated from other texts with one newline character by default.
FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM = 4
Flag indicating that texts inside <li> elements will be separated from other texts with one newline character by default.
FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH = 1
Flag indicating that texts inside <p> elements will be separated from other texts with one newline character by default.
TO_HTML_PARAGRAPH_LINES_CONSECUTIVE
public static final int TO_HTML_PARAGRAPH_LINES_CONSECUTIVE = 0
Option for fromHtml: Wrap consecutive lines of text delimited by '\n' inside <p> elements. BulletSpans are ignored.
TO_HTML_PARAGRAPH_LINES_INDIVIDUAL
public static final int TO_HTML_PARAGRAPH_LINES_INDIVIDUAL = 1
Option for fromHtml: Wrap each line of text delimited by '\n' inside a <p> or a <li> element. This allows ParagraphStyles attached to be encoded as CSS styles within the corresponding <p> or <li> element.
Public methods
fromHtml
public static @NonNull Spanned fromHtml(@NonNull String source, int flags)
Invokes fromHtml on API 24 and newer, otherwise flags are ignored and fromHtml is used.