Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


A library for displaying math formula in Android apps.

Subscribe to updates I use MathView

Statistics on MathView

Number of watchers on Github 783
Number of open issues 38
Average time to close an issue 2 days
Main language Java
Average time to merge a PR less than a minute
Open pull requests 1+
Closed pull requests 2+
Last commit about 4 years ago
Repo Created over 4 years ago
Repo Last Updated about 2 years ago
Size 4.08 MB
Organization / Authorkexanie
Page Updated
Do you use MathView? Leave a review!
View open issues (38)
View MathView activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating MathView for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


Android Arsenal Download

MathView is a third-party view library, which might help you display math formula on Android apps easier. Two rendering engines available: MathJax and KaTeX. Support Android version 4.1 (Jelly Bean) and newer.


There are two ways you can add MathView to your project in Android Studio:

  1. From a remote Maven repository (jcenter).
  2. From a local .aar file.

1. Setup from a remote Maven repository (jcenter)

Add compile 'io.github.kexanie.library:MathView:0.0.6' into dependencies section of your module build.gradle file. For example:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'io.github.kexanie.library:MathView:0.0.6'

2. Setup from local .aar file

You can download the latest version of MathView from Bintray.

1) Import the module from local .aar file

Click File -> New -> New Module (yes, not import Module) -> Import .JAR/.AAR Package, and find out where the file located.

2) Add dependency

Click File -> Project Structure -> Dependencies, and then click the plus icon, select 3. Module Dependency.

For Eclipse users

Just migrate to Android Studio.


The behaviour of MathView is nearly the same as TextView, except that it will automatically render TeX code (or MathML code if rendering with MathJax) into math formula. For basic tutorial and quick reference, please have a look on this tutorial.


  1. You should enclose the formula in \(...\) rather than $...$ for inline formulas.
  2. You need to escape spacial characters like backslash, quotes and so on in Java code.
  3. If you want to make the height of MathView actually wrap_content, warp the views into NestedScrollView.

About the engines

KaTeX is faster than MathJax on mobile environment, but MathJax supports more features and is much more beautiful. Choose whatever suits your needs.

Define MathView in your layout file

For example:

<LinearLayout ...>

        android:text="Formula one: from xml with MathJax"

        auto:text="When \\(a \\ne 0\\), there are two solutions to \\(ax^2 + bx + c = 0\\)
        and they are $$x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.$$"

        android:text="Formula two: from Java String with KaTeX"



Get an instance from your Activity

public class MainActivity extends AppCompatActivity {
    MathView formula_two;
    String tex = "This come from string. You can insert inline formula:" +
            " \\(ax^2 + bx + c = 0\\) " +
            "or displayed formula: $$\\sum_{i=0}^n i^2 = \\frac{(n^2+n)(2n+1)}{6}$$";

    protected void onCreate(Bundle savedInstanceState) {

    protected void onResume() {

        formula_two = (MathView) findViewById(R.id.formula_two);

Noted that the method MatView.getText() will return the raw TeX code (Java String).


I am not an expert in MathJax. Rather than providing a pre-configured version of MathJax, I choose to add another method config()(for MathJax only) to MathView in version 0.0.5. You can tweak MathJax with more complicated configurations. For example, to enable auto linebreaking, you can call

            "  CommonHTML: { linebreaks: { automatic: true } },\n"+
            "  \"HTML-CSS\": { linebreaks: { automatic: true } },\n"+
            "         SVG: { linebreaks: { automatic: true } }\n"+

before setText().

How it works

MathView inherited from Android WebView and use javascript ( MathJax or KaTeX ) to do the rendering stuff. Another library called Chunk is just an lightweight Java template engine for filling the TeX code into an html file. So we can render it. It's still rather primitive, but at least functional. Check the code for more details.

Known Issues

  1. When rendering with MathJax, some characters are blank(like character 'B' of BlackBoard Bold font) due to MathJax's bug on Android WebView.
  2. Not all TeX commands are supported by KaTeX, check this link for more details.


If you have any issues or need help please do not hesitate to create an issue ticket.

MathView open issues Ask a question     (View All Issues)
  • over 3 years Rendering problems
  • over 3 years KaTeX \underline not working
  • almost 4 years mathview not properly rendered when with non-english words
  • almost 4 years Slow while loading equation type content.(MathML) in android
  • almost 4 years Mathjax $$ problem
  • almost 4 years Unable to open asset
  • almost 4 years app crash
  • almost 4 years Unable to downlaod .aar file from bintray
  • almost 4 years autoEngine error
  • almost 4 years NoSuchMethodError: getSettings()
  • about 4 years Blank screen till MathView render content
  • about 4 years MathView didn't fit in screen size
  • about 4 years Load complete callback
  • about 4 years Unable to scroll after update
  • about 4 years Able to style formulas with text aligned right?
  • over 4 years Automatic line breaking
  • over 4 years What are the proguard rules to be added for the library ?
  • over 4 years LaTeX not working on MathJax android 4.0
  • over 4 years Not Show "A" character on Lenovo P780 running Android 4.2.1 (API 17)
MathView open pull requests (View All Pulls)
  • Fix for issue #29
MathView list of languages used
More projects by kexanie View all
Other projects in Java