https://github.com/sunfusheng/codeviewer
Android 端代码查看器
https://github.com/sunfusheng/codeviewer
Last synced: 2 months ago
JSON representation
Android 端代码查看器
- Host: GitHub
- URL: https://github.com/sunfusheng/codeviewer
- Owner: sunfusheng
- Created: 2020-02-18T03:15:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-21T06:56:02.000Z (about 3 years ago)
- Last Synced: 2025-03-22T22:24:09.478Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 331 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CodeViewer
Android 端代码查看器,支持的功能:
1、几乎加载所有格式代码,具体查看Google开源的[code-prettify](https://github.com/google/code-prettify)
2、支持白天夜晚模式,可以设置自定义颜色
3、支持是否显示代码行号### 效果图
### Gradle:
api 'com.sunfusheng:code-viewer:1.0.0'
### 使用
// 1、从assets文件夹下加载文件的内容
val sourceCode = CodeViewUtil.getStringFromAssetsFile(context, filePath)
// 2、生成html字符串
val sourceCodeHtml = CodeHtmlGenerator.generate(filePath,sourceCode,isNightMode,showLineNums)
// 3、在UI线程中加载源码的Html字符串,步骤1和2应该放到子线程中
vCodeView.loadCodeHtml(sourceCodeHtml)
### 感谢
1、[google/code-prettify](https://github.com/google/code-prettify)
2、[ThirtyDegreesRay/OpenHub](https://github.com/ThirtyDegreesRay/OpenHub)
### 关于我
[GitHub: sunfusheng](https://github.com/sunfusheng)
[个人邮箱: [email protected]](https://mail.126.com/)
[个人博客: sunfusheng.com](http://sunfusheng.com/)
[简书主页](http://www.jianshu.com/users/88509e7e2ed1/latest_articles)
[新浪微博](http://weibo.com/u/3852192525)