• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

falnatsheh/MarkdownView: MarkdownView is an Android webview with the capablity o ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

falnatsheh/MarkdownView

开源软件地址(OpenSource Url):

https://github.com/falnatsheh/MarkdownView

开源编程语言(OpenSource Language):

CSS 54.0%

开源软件介绍(OpenSource Introduction):

MarkdownView screenshot Download

About

MarkdownView (Markdown For Android) is an Android library that helps you display Markdown text or files (local/remote) as formatted HTML, and style the output using CSS.

The MarkdownView itself extends Android Webview and adds the necessary logic to parse Markdown (using MarkdownJ) and display the output HTML on the view.

Getting started

  • To add MarkdownView to your project, add the following to build.gradle file:
	dependencies { 
	    compile 'us.feras.mdv:markdownview:1.1.0'
	}

Usage

Add MarkdownView to your layout:

    <us.feras.mdv.MarkdownView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/markdownView" />

and reference it in your Activity/Fragment:

MarkdownView markdownView = (MarkdownView) findViewById(R.id.markdownView);
markdownView.loadMarkdown("## Hello Markdown"); 

Note: You could also create the view by code. Below an example of how to set the whole activity to be a MarkdownView by Adding the following to your onCreate method:

  MarkdownView markdownView = new MarkdownView(this);
  setContentView(markdownView);
  markdownView.loadMarkdown("## Hello Markdown"); 

Screenshots

Demo App and Code Sample

The above screenshots taking from the demo app which could be found here. The demo app include code to demonstrate:

  • Loading Local Markdown File.
  • Loading Remote Markdown File.
  • Loading Markdown text.
  • Live Preview sample code (similar to Marked Mac app)
  • Themes

Loading Markdown text or file:

  • loadMarkdown(String text): Using this method will result in loading md string to the MarkdownView and displaying it as HTML.

  • loadMarkdownFile(String url): You can use this method to load local or online files.

To load a local file, you have to add it to your assets folder and pass a url that start with "file:///android_asset/" :

markdownView.loadMarkdownFile("file:///android_asset/myFile.md");

To load a remote file you need to pass the full url :

markdownView.loadMarkdownFile("http://www.my-site.com/myFile.md");

Theming

You could apply custom CSS to the MarkdownView. Example:

markdownView.loadMarkdownFile("file:///android_asset/hello.md","file:///android_asset/MyCustomTheme.css");

You could take a look at CSS example here, you could also view them in the sample app.

ChangeLog:

  • MarkdownView 1.1.0:
    • Support Loading Markdown file from assets subfolders (Thanks @echodjb).
  • MarkdownView 1.0.0:
    • Convert to Gradle Project (Avillable now on jCenter).
    • Fix CSS Issue (Thanks @swanson & @echodjb).
    • Update demo app.

License

Apache 2.0




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
erusev/parsedown: Better Markdown Parser in PHP发布时间:2022-08-17
下一篇:
preservim/vim-markdown: Markdown Vim Mode发布时间:2022-08-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap