MathView icon indicating copy to clipboard operation
MathView copied to clipboard

Katex Not supporting textSize

Open ParveshChauhan opened this issue 7 years ago • 2 comments

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" > </com.parvesh.Lib118.MathView>

ParveshChauhan avatar Apr 12 '17 06:04 ParveshChauhan

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 + "" but maybe it won't work that easily..

OR

you can use hourglass version of MathView

Aiosa avatar Dec 30 '17 22:12 Aiosa

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 .

MisterPotz avatar May 08 '20 08:05 MisterPotz