Need help with CodeView?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

tiagohm
203 Stars 30 Forks MIT License 53 Commits 2 Opened issues

Description

Android Code Highlighter

Services available

!
?

Need anything else?

Contributors list

# 73,152
Android
android...
highlig...
Java
52 commits

CodeView

Android Code Highlighter

Install

Add it in your root

build.gradle
at the end of repositories:
gradle
allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}
Add the dependency:
gradle
compile 'com.github.tiagohm:CodeView:LATEST-VERSION

Features

  • Powered by Highlight.js
  • 176 languages and 79 styles
  • Wrap Line
  • Language Detection
  • Zoom (Pinch gesture)
  • Line Number
  • Line Count
  • Highlight current line (by click/tap)
  • Highlight line
  • Tap event of lines (get line number and your content)

Usage

Add view to your layout:

xml

    
```java mCodeView = (CodeView)findViewById(R.id.codeView);

mCodeView.setOnHighlightListener(this) .setOnHighlightListener(this) .setTheme(Theme.AGATE) .setCode(JAVA_CODE) .setLanguage(Language.JAVA) .setWrapLine(true) .setFontSize(14) .setZoomEnabled(true) .setShowLineNumber(true) .setStartLineNumber(9000) .apply(); ```

Other Methods

mCodeView.highlightLineNumber(10);
mCodeView.toggleLineNumber();
mCodeView.getLineCount();

Listeners:

 //Interface
 new CodeView.OnHighlightListener()
 {
  @Override
  public void onStartCodeHighlight()
  {   
    mProgressDialog = ProgressDialog.show(this, null, "Carregando...", true);
  }

@Override public void onFinishCodeHighlight() { if (mProgressDialog != null) { mProgressDialog.dismiss(); } }

@Override public void onLanguageDetected(Language language, int relevance) { Toast.makeText(this, "language: " + language + " relevance: " + relevance, Toast.LENGTH_SHORT).show(); }

@Override public void onFontSizeChanged(int sizeInPx) { Log.d("TAG", "font-size: " + sizeInPx + "px"); }

@Override public void onLineClicked(int lineNumber, String content) { Toast.makeText(this, "line: " + lineNumber + " html: " + content, Toast.LENGTH_SHORT).show(); } }

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.