From 09e45f2916ad001a53ccf6ebe92afdcb337d326f Mon Sep 17 00:00:00 2001 From: Cyrus Bakhtiari-Haftlang Date: Tue, 14 Aug 2018 11:28:54 +0200 Subject: [PATCH] Updated the README to reflect the support for styling through XML --- library-view/README.md | 68 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/library-view/README.md b/library-view/README.md index 71f032db..5213be4e 100644 --- a/library-view/README.md +++ b/library-view/README.md @@ -30,6 +30,25 @@ These are XML attributes: ``` app:mv_markdown="string" app:mv_configurationProvider="string" + +app:mv_H1Style="reference" +app:mv_H2Style="reference" +app:mv_H3Style="reference" +app:mv_H4Style="reference" +app:mv_H5Style="reference" +app:mv_H6Style="reference" + +app:mv_EmphasisStyle="reference" +app:mv_StrongEmphasisStyle="reference" +app:mv_BlockQuoteStyle="reference" +app:mv_CodeSpanStyle="reference" +app:mv_MultilineCodeSpanStyle="reference" +app:mv_OrderedListItemStyle="reference" +app:mv_BulletListItemStyle="reference" +app:mv_TaskListItemStyle="reference" +app:mv_TableRowStyle="reference" +app:mv_ParagraphStyle="reference" +app:mv_LinkStyle="reference" ``` `mv_markdown` accepts a string and represents raw markdown @@ -38,4 +57,51 @@ app:mv_configurationProvider="string" for example: `com.example.my.package.MyConfigurationProvider` (this class must have an empty constructor in order to be instantiated via reflection). -Please note that those views parse markdown in main thread, so their usage must be for relatively small markdown portions only +Please note that those views parse markdown in main thread, so their usage must be for relatively small markdown portions only. + +An `mv_*Style` may refer to an actual style or a theme attribute that resolves to a style as well as support for `android:textAppearance` which is basically a sub-style. Currently the following attributes are supported: +* `android:textColor` +* `android:textColorLink` +* `android:textSize` +* `android:textStyle` +* `android:fontFamily` +* `fontFamily` +* `android:typeface` +* `android:textAppeance` + * `android:textColor` + * `android:textColorLink` + * `android:textSize` + * `android:textStyle` + * `android:fontFamily` + * `fontFamily` + * `android:typeface` + +A theme level style may be set through the theme attribute `markwonViewStyle`. + +Note that, just like `TextView`, values included in `textAppearance` are canceled by values in the root style. Also mimicking `AppCompatTextView`, `android:fontFamily` takes precedence over `fontFamily`. + +## Example +```XML + +``` +In the above example, the paragraph text will get the style of the widget itself `style="?android:textAppearanceSmall"`. If a particular markup style is not specified or specified as `@null` Markwon's original spans will be applied for text with that markup. Otherwise the styling will be based on the resolved attributes. By supplying a valid `app:mv_ParagraphStyle` the default text (paragraph) will be spanned explicitly. \ No newline at end of file