Open ParveshChauhan opened 7 years ago
Well its not about katex, its about HTML settings. You can both modify MathView java file and add a new method setTextSize which would simply modify string, something like inputText = "<div style=\"text-size:" + size + ";\">" + inputText + "
OR
you can use hourglass version of MathView
Aiosa's answer helped me to solve the problem. Some corrections to the code:
fun setTextSize(string: String, textSizeInSp : Int) : String { return """<div style="font-size:${textSizeInSp}px;"> $string </div>""" }
Setting font size in Sp unit makes MathView text look almost like normal TextView text with the same sp size. I guess that's because WebView makes some additional work for these measurement kind of things.
The returned string can be directly passed to MathView#setText .
When I using it in my android project ,the size of text is small even if i setting textsize property to some value in xml file it shows same size text.Also problem in centring the text.Here is my code.
` <com.parvesh.Lib118.MathView android:id="@+id/tvQuestionText" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:textSize="20sp" 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}.$$" auto:engine="KateX"