This is a lightweight support library for MarkdownView
. MarkdownView
is a Markdown renderer for Android. It has backward compatibility with API 7 and higher. For more information, see the original project.
NOTE: Some unimportant features of MarkdownView
have been removed in order to make the library lighter.
To add MarkdownViewSupport
library to your project, add the following to build.gradle
file:
dependencies {
implementation 'boxresin.library:MarkdownViewSupport:2.0.0'
}
Add <MarkdownView/>
to your layout:
<us.feras.mdv.MarkdownView
xmlns:mdv="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
mdv:cssFromAssets="markdown_css_themes/paperwhite.css"
mdv:markdown="## Hello Markdown"
android:id="@+id/markdownView" />
cssFromAssets
attribute is optional. If you want to apply custom style to the Markdown text, you should make a CSS file at assets
directory and attach its path to cssFromAssets
attribute. You can also use markdownFromAssets
attribute to set Markdown text from the assets
as well.
and refer it in your Activity/Fragment:
val markdownView = findViewById<MarkdownView>(R.id.markdownView)
It's also possible to create the view in code. Do like this in your onCreate
method:
val markdownView = MarkdownView(this)
setContentView(markdownView)
mainScope.launch {
markdownView.commit {
loadMarkdown("## Hello Markdown")
loadCssFromAssets("markdown_css_themes/paperwhite.css")
}
}
NOTE: If you don't want to use Kotlin coroutine, see 1.x version
For more information, see Whole XML attributes and methods of MarkdownView.
You could take a look at CSS example here, you could also view them in the sample app.
Copyright 2017 Minsuk Eom
Copyright 2011 Feras Alnatsheh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.