MathJax with TextView in Android - android

I have some data which was formatted using MathJax on WebApplication. Now, I want to display those Data in Android App and that is in TextView only.I have already downloaded MathJax from Leathrum's WordPress
I found some examples but all are using WebView. But I want it using TextView. How to get this ???
I am also using ImageGetter with that TextView and it is working fine. Now, just want to do something for MathJax.
Why only TextView ???
My data contains simple text, html text, images, and math functions... I was using webview but it is showing extra space at bottom and also have using with Webview because I am using Custom ListView with WebView

But I want it using TextView. How to get this ?
You don't. TextView is not designed for this. Your choices are:
Stick with WebView
Figure out how to render your mathematical expressions to images, then either use an ImageView, ImageSpan, etc.
Write your own widget that draws the mathematical expression to a Canvas

MathJax is a cross-browser JavaScript library that displays mathematical notation in web browsers, using MathML, LaTeX and ASCIIMathML markup.
Source: MathJax in Wiki
The very first line has an answer for you. It's a cross-browser javascript library. you can not use it for textviews. Doesn't it make sense ?
Update:
Solution 1: You could write a mapper which will have mapping of each Math symbols to its html code and use it to showcase on your TextView based on need.
Solution 2: There is a nice open source: MathView Which is using MathJax internally that you can use.

Related

Justifying database texts on android

I'm working on story application pjoject for android. The story text is in the database/db file. I used textView and the text is working good on the application but it's not justified. Is there a way to justify the text from database file, or link to that tutorial?
Setting text in db won't have any styling impact on text itself. You can use third-party lib to justify your text in android.
https://github.com/bluejamesbond/TextJustify-Android
In order to use it, you'll need to use their com.bluejamesbond.text.DocumentView in XML instead of traditional TextView. See the first example of the following link to get an idea about code.
https://github.com/bluejamesbond/TextJustify-Android/wiki/3-%C2%B7-Examples

Android: Html.fromHtml() method not working with standard Html tags

So I have an HTML string I want to display as styled text in a textview but it never seems to work. My HTML string uses tags which are supposed to be supported by the fromHtml() method but it never displays the text properly, just returns the original HTML string. Here's an example of my HTML:
<div class="className"><p>Sample text http://www.example.com</p></div>
Nothing special as you can see, yet it never parses it correctly. Could it be that the method doesn't support the "class" attribute? If so, how do I add support for it?
Html class provides limited to support of HTML elements. And "class" attributes are not supported.
To understand which tags can be used and how they will be rendered refer to source code (android 5.0.1 r1). You can provide custom TagHandler or use WebView to display complex HTML page.
Give a try to this lib: https://github.com/SufficientlySecure/html-textview
It supports several tags more than native Html.fromHtml in Android.

Create a nice "About" XML Layout using rich text?

I intend to make a good "About" section in my application that gives the user some basic information about the developer and the app itself.
I didn't find a rich EditText among the Widgets.
I have searched for other questions similar to mine here and I found something like using a WebView or a TextView and giving them HTML attributes in the code.
Is there any nice and professional way to do my About XML Layout?
use multiple TextViews and position them accordingly.
If you need high control and rich text, use a WebView and load a static HTML file. You can achieve a lot with Spans (bold, itallick, links, etc.) in a simple TextView as well but it is generally more work.

Android: Render HTML not supported by Html.fromText

If I have html with tags not supported as part of Html.fromText I understand a WebView will do the trick as it supports standard HTML as a browser but its performance is really slow to my liking. So if I don't want to use WebView, the only other way is to parse the HTML myself and put different tags in muliple TextView inside a vertical LinearLayout?
You'll have to use Html.fromHtml() with an Html.TagHandler to handle unknown tags like <pre/> and <code/>.
See this answer for an example of how to implement Html.TagHandler.
Use replaceAll() to convert the <pre> and <code> tags to <tt>, which is supported by Html.fromHtml(). Then, use Html.fromHtml() to create the SpannedString that you pass to the TextView.

Arabic Font in android webview?

We have site urls having arabic language we want to display as it is in android webview but it is not showing as correctly it is showing in reverse. Can you help me????
There is a simple solution of it. As correct order letters display in reverse order. Why not we write reverse letters?
This link will help https://stackoverflow.com/a/13562693/1547539
Just set the encoding :
YourWebView.loadData(YourContentHtml, "text/html; charset=UTF-8", null);
I fully understand your issue, you mean:
[أحمد] Would show as [دمحا]
I am afraid this is not possible, I have seen some post around all confirm that can't be done in the mean time.
Android has the ability to use custom TTFs in views (though it's kind of a kludge, example on how to use custom typefaces in the API Demos), but I'm not sure how to extend this to WebView, or whether it's even possible. custom font with Webview
Also see: font face of Webview in Android?

Categories

Resources