How to show special characters in Android? - java

I am developing a native app which consists of some mathematical formulas.
Formulas will be like.........
I want to display such formulas in my application, but i don't how to use these special characters in Android. I want to display each formula individually in a list view...... If i am copying formula & if i am setting text to text view means it is showing like
txtv.setText("\\cos^2\\theta + \\sin^2\\theta = 1\\! ");
and getting output in the same pattern. So, can anyone help me how to use these mathematical special characters in Android..

Sorry, there are not a lot of different solutions..
There are no 'magical answer", here are some different ways to achieve what you want.
1) Using a webview with some Javascript
2) using a server to produce a picture of the formula.
3) Using a 9.png file embededd in your app with the square root symbol and display it as textview background
4) Drawing a canvas with all your text and symbols
5) using Hexadecimal code: http://htmlhelp.com/reference/html40/entities/symbols.html
http://tlt.its.psu.edu/suggestions/international/bylanguage/mathchart.html
6) Maybe other ideas, but definitely no way to achieve a 300 formula listview in a easiest way.

This one seem quite good and works in Android without any issue: http://mathscribe.com/author/jqmath.html
Edit:
You can run this inside a WebView, you don't need any webapp.

Related

How to start first line in text view(paragraph) in middle - android

I am new to Android. I have a paragraph in string which looks like below
String my_paragraph ="Software is a set of instructions, data or programs used to operate computers and execute specific tasks. It is the opposite of hardware, which describes the physical aspects of a computer. Software is a generic term used to refer to applications, scripts and programs that run on a device."
textView.setText(my_paragraph);
I want to display it in the Text View like this below image:
But what I got is I added below
I want the first line in text view(paragraph) should starts in the middle. I don't want to add leading spaces in string. I don't know how to achieve this. Please help me with some solutions.
Android has libraries that can do this for you. I found an old post with a great how to use the SpannableString and LeadingMarginSpan libraries.
The question can be found at: What is Leading Margin in Android?
try to add \t or \u0009 (tabulator character) at the begining of String - this is a symbol of default indetation for paragraphs
textView.setText("\u0009" + my_paragraph);

How to create or add a text editor to input mathematical equations using swing?

I am working on a project of question paper generator(offline) which requires the the user to input the questions. Obviously there will be some questions of mathematics as well hence I need to invoke or create a text editor that will create mathematical expressions such as integral symbol or limit operator etc.
I am using java swing GUI and mysql database to achieve the purpose and hoping to use JEditorPane for text area.
Please help me , I took about a day to search the internet to solve this problem.
And also I need to know whether the mathematical expression the text editor will create could be stored in mysql database column?
Things I tried:-
Tried changing the text type of JEditorPane to text/html but I realised that I can add subscript, superscript and even images but this wont add that beautiful LaTeX mathematical expressions and many complex operators.
Tried using JMathTex but I couldn't resolve how it will enable the user to input the expressions, according to me JMathTex is not the solution to my problem.
Even thought tries of using MathJax but it requires java script and JEditorPane does not support java script.
I repeat the problem, I want to create a text editor (just like MathType) in my swing application so that user can input the question along with the required expressions so that the question can be added to database for random generation.

opencv find block of text areas / detect document layout

I have color image document with text and images and tables.
Document can have two columns.
Document is composite from areas: area header and text (bigger font, can have different font color and something like sub-header additional data).
This is exemplary image but real one can be color:
What i need to do.
I need find on image document this areas of text with headers.
What i need to know.
Method how to divide document to divide document on particular parts.
I try with opencv in java(if someone have python and c++ version i can convert it for java version by myself). I found few similar problem on stack overflow, but none of them can help me. You must know that my opencv knowledge is not very well and it is only from on-line tutorials and stack overflow.
Is there any fine solution on my problem in opencv way or i need use something else, different library or application to achieve this?
One and only requirement is that it must be done from command line.
If i had this areas i can do what i need next, but this is step which stops me.
have you solved the problem?
I'm working on a similar problem.
My solution is to use HoughLines https://docs.opencv.org/3.4.0/d9/db0/tutorial_hough_lines.html
You can use text detection combined with dilation to detect bold text i.e. headers and then group the text boxes between two consecutive headers as the text under first header.

Math Formatting in native Android? MathView library not working

I am creating a quiz app which includes some chemical and mathematical equations. I had a previous version that used a WebView and jqmath library to display the files. That version was very inefficient and was dead slow in old android phones (2 year old ones). I scraped that thing and started the quiz page again.
I have a TabLayout and a CardView. TabLayout is used to switch between the questions and CardView is used to display the questions. But I have the database setup in such a way that if two $$ occur in a string then use jqmath to format the string.
For eg : if the json is like this "Qno":5,"Question":"If the point represented by the complex number iz is rotated about the origin through the angle $$\u03c0\/2$$ in the counter clockwise direction then the complex number representing the new position is:","Option1":"iz","Option2":"-iz","Option3":"-z","Option4":"z","Correct":"C"
then the output is
I can take care of the $$ symbol with some java functions but I have no idea how to make the expression (pi divide by 2) appear as should be. When I used jqmath my output was something like this
How to achieve this in native android using java without affecting my existing code...??
UPDATE
As suggested in the comments I used this library. But this is not working properly. Sometimes it is rendering correctly sometimes not.
For Eg: Correct Rendering
Wrong Rendering
The TextView in the top is just a normal TextView that is showing the text that is being displayed. WebView is the set of text that is displayed below that.
What is wrong? Any help is appreciated

WebView with ViewFlipper w/ one website

I have some html files on my server that are displayed using a WebView. The html files are quite lengthy, meaning they have a lot of text (for example one is a copy of the US Constitution). Instead of letting the user simply scroll down the WebView to display the rest of the HTML file I was wondering if there is some way I could use ViewFlipper to "flip" to the next section of the HTML file's text. Basically what I mean is instead of scrolling, you "flip" the WebView content to view the rest of it. I am not sure if this is even possible and I apologize if what I am trying to do is not clear with my question. I appreciate any help or approaches to take or ideas on how one could do this. Thanks.
I'm using this two library. both are free and opensource.
TurnJs
Booklet
I think this is only possible in case of responsive website's only.
Other websites can't able to scroll because the minimum Desktop resolution screen is 1024 * 768. where as in case of mobile it is as low as 240 * 320 and it goes up to 5 inch , up to 10 inch in case of tablet.

Categories

Resources