Reputation: 65
I'm new at this forum, this is my first post. So, I've created an app with custom keyboard that displays, mathematical characters , such as integrals, sinus, power ... .After that , I wanted to insert these characters on a EditText , that works fine , but the problem is I wanted to create a mathematical expression something like this https://ibb.co/F7j22BY.
What I have tried: - I have tried Mathjax, which is for web and not for mobiles , so the only way is to show the expression on a webview, and it's not what I really wan't.
Upvotes: 4
Views: 2156
Reputation: 2269
Check out this library. https://github.com/jianzhongli/MathView
To add this library to your project, go to your build.gradle (module) and add:
implementation 'io.github.kexanie.library:MathView:0.0.6'
Then define MathView
in XML Layout File
<LinearLayout ...>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Formula two: from Java String with KaTeX"
android:textStyle="bold"/>
<io.github.kexanie.library.MathView
android:id="@+id/formula_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
auto:engine="KaTeX"
>
</io.github.kexanie.library.MathView>
Then, configure it in your Code.
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}$$";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
formula_two = (MathView) findViewById(R.id.formula_two);
formula_two.setText(tex);
editText.setHint(formula_two.getText().toString());
}
}
to set EditText hint just use editText.setHint(formula_two.getText().toString)
So you could make the MathView Invisible somewhere but retrieve its text
Upvotes: 1
Reputation: 1431
jqMath is a JavaScript module that makes it easy to put formatted mathematical expressions in your activity. you can download it online. download Jqmath from this link
Upvotes: 0