Markdown View for Android, based on markdown-it and WebView.
![]() |
![]() |
![]() |
- Auto fit system theme
- Code Highlighting(highlight.js)
- HTML
- KaTeX(katex and markdown-it-katex)
- Container(info, success, warning, error)
Add it in your root build.gradle at the end of repositories(for older gradle version):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Or add following to settings.gradle(for newer gradle version):
dependencyResolutionManagement {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.imcloudfloating:markdown-it-android:1.0.4'
}
Required SDK Version >= 22.
Data Binding:
<com.github.imcloudfloating.markdown.MarkdownIt
android:id="@+id/markdown_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:markdownString="@{viewModel.content}" />
No Data Binding:
val md = "# Hello, Markdown!"
findViewById<MarkdownIt>(R.id.markdown_view).markdownString = md
If the HTTP image link cannot be displayed, add
android:usesCleartextTraffic="true"
toAndroidManifest.xml
of your project.
Field/Method | Note |
---|---|
fitSystemTheme |
Default is true , auto fit system theme. |
darkTheme |
Use dark theme when fitSystemTheme = false |
markdownString |
The markdown content you want to show. |
urlClickListener |
Click listener for link. |