Suppose Html body is having below content
qwweeerrt
asssdfghjjkl
zxxcvbnmm
It is shown like below :
qwweeerrtasssdfghjjklzxxcvbnmm
when I used
webView.loadData()
and
qwweeerrt asssdfghjjkl zxxcvbnmm when I used
webView.loadDataWithBaseURL()
So empty lines between qwweeerrt , asssdfghjjkl and zxxcvbnmm are missing in webview.
Please suggest me how to show the content as it is.
HTML (not the WebView itself) hates blanks.
Please use the <br/> tag to add a carriage return.
Double it, for an empty line.
If you want to add some blank spaces, use for each space you want.
Or, as an alternative, include your text in a
<pre>
Your multiline text here
Second line
Third line
</pre>
structure.
The WebView only renders the HTML (but also CSS and JavaScript).
And it does a great job.
I recommend you to study some HTML, if you plan to use a WebView in your app.
A great (and historically proven to be accurate) learning source is found here.
Your 'content' has to be more formatted. Proper way to show it would be like.
<p>qwweeerrt</p>
<p>asssdfghjjkl</p>
<p>zxxcvbnmm</p>
See what the webView.loadData() shows now.
Related
Let’s say I have a function that receives a string that represents a text in HTML format and I want to show this text in Flutter. Some words in the text are supposed to be bold. If I have a few bold words in a row, the spaces between the tags are ignored. How can I show the text without it ignoring spaces?
For example if I use this code and wrap the text with the Html widget:
Html(data: "<b>hello</b> <b>world</b>"),
It shows helloworld but I want it to show hello world .
(If I don’t wrap it in Html the spaces are printed but I do need to render Html to a Flutter widget)
I would really appreciate your help.
Use a non-breaking space entity ( ).I don't know if it will work or not, but you should try this.
Html(data: "<b>hello</b> <b>world</b>"),
I ended up using this line and it worked:
Html(data: text.replaceAll("</b> <b>", "</b> <b>")),
I have gone through this link for reference
https://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
The information is right there on your link. To use it as a spannable you have to call the fromHtml() method on your textview. After initializing the component. Please refer to this question:
How to display HTML in TextView?
All your answers are there, sorry for not formatting the answer correctly I'm on mobile at the moment
I am creating a mathematics app and have to display mathematical equations in my app. There are many answers related to this but I am not able to conclude how to do this?
As mentioned in the comments above you can use that library MathView or other possibilities are ,
You can go with using the spannable string and can make superscripts
and subscripts easily.
You can also use the HTML.fromHTML(String html) which will give you
the spanned text and that you can set it to the TextView.
Or else show a webview and load the html page that contains the
formulas and solutions. (This will be like creating a dynamic html
files with in the app and showing it in the Webiew)
I am working with HTML and Unicode text that I'm querying from a database. I'm trying to convert it for proper display in a text view.
Here is the relevant code where I'm attempting the conversion:
ReviewView.setText(Html.fromHtml(URLDecoder.decode(cursor.getString(14), "UTF-8")).toString());
However, it's only partially working. Here is an example of the text I'm working with:
is%20in%20the%20title.%3C/p%3E%3Cstrong%3EBoiled%20Brocoli%3C/strong%3E%3Cbr%20/%3EApparently%20brocoli%20does%20not%20make%20for%20a%20good%20pesto.%20This%20tasted%20like%20brocoli%20I%20used%20to%20cook%20when%20I%20was%20eleven%20at%20home%2C%20which%20is%20to%20say%20I%20don%27t%20really%20remember%20it.%3C/p%3E
I want it to look like:
is in the title.
Boiled Broccoli
Apparently broccoli does not make for a good pesto. This tasted like broccoli I used to cook when I was eleven at home which is to say I don't really remember it.
Instead I'm getting:
is in the title.Boiled Broccoli
Apparently broccoli does not make for a good pesto. This tasted like broccoli I used to cook when I was eleven at home which is to say I don't really remember it.
Any ideas on how to properly decode this?
Thanks!
The start of the Paragraph tag is wrong. in your case,it starts with a end tag, like this < / p > (added space inside the tags for clarity). Also replace the strong tag with b. It should work now.
Separating the commands actually fixed this. So on separate lines I complete first the decode then the fromHTML.
I've searched the Internet for a solution but I can't find it.
I have a WebView that display text, Just text. I want to wrap the text in the WebView, is that possible, or what?
And I want to make the user be able to select a certain text in the WebView and make him able to send the selected text by SMS, is that possible to?
I found the solution. You have to add some div tag on your web document, and then add a css class. I did this:
<div class="wrap">
with a css class like this:
.wrap {
word-wrap:break-word;
}
If the content in the WebView is something that you yourself have created or have control of, use a stylesheet optimized for mobile devices, or you can use jTouch or jQuery Mobile
If your content is literally plain text (no HTML markup), then the WebView will be treating it as preformatted text and won't wrap or insert linebreaks.
Try wrapping your text in an HTML wrapper:
<html><body>My text goes here</body></html>