Android : Html.fromHtml() not showing output same as web - android

I have attached screenshots for web and app.
In web
Inside textview

Html.fromHtml() isn't supporting all HTML tags, check out supported list in HERE and THIS SO topic. its very basic implementation which doesn't supported e.g. nested <span tags (looks like) - closing tag </span> is closing ALL opened previously spans, not only last one (so your red background breaks after first span-styled letter, when orange-coloring-span is closed)
if you want full support of HTML content - use WebView and loadData method

Related

empty lines are missing in webview

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.

How can I get Chromecast correctly display unicode characters using custom receiver?

I've setup a custom receiver application using CastHelloText-android as a base, and I'm trying to get it to correctly display certain unicode characters, however it is just displaying a blank space instead where the characters should be.
<div id="message">Test: ਵਾਹਿਗੁਰੂ :End Test</div>
This renders correctly on the site where I'm hosting the custom receiver, but when attempting to display it using a DataCastManager from the Cast Companion Library, the unicode characters aren't showing up. Is there any way to make this display or is there an alternative?
UPDATE:
I just tried the message:
<div id="message">Test: ग़ ਵਾਹਿਗੁਰੂ :End Test</div>
And the character (ग़) for
ग़
shows up just fine. I'm assuming this is a supported language issue then?
Update2: To help clarify, here is the result I'm getting after casting from a device connecting to my receiver with the above message:
Google responded at: https://code.google.com/p/google-cast-sdk/issues/detail?id=794
And thanks Ali, your suggestion was correct. Using a .ttf font and applying it to the text will allow the characters to show up. It's not the same as having the actual unicode characters show up, but still helps.

Android WebView: scrollIntoView not working on epub pagebreak span

My app features a WebView where a local HTML page is loaded.
The page has
<span id="page752" epub:type="pagebreak">752</span>
somewhere embedded in text.
I get the element with id="page752" by means of getElementById function, then I call
element.scrollIntoView(true);
but it doesn't work, that is, no scroll is performed.
Note that the element text ("725") is not displayed in the WebView. Maybe this is related to the scroll not being performed.
How to make the span able to scrollIntoView?

HTML A Name attribute on android browser

I have a web page with about 150 HTML <a name="blah"></a> elements, plus 26 more that group these by letter, like <a name="lettera"></a>.
The page passes W3C HTML validation and renders and operates correctly in desktop browsers. Trying two different Android browsers and an emulator, the letter index does not work. When any letter is selected, the page only moves to the lettera tag. The location bar correctly shows <site>page.htm#letterx as the current location, but the display has not moved.
Other pages on the same site with a smaller number of name tags work correctly. I found one web reference saying that some browsers did not like to see two name tags in a row and suggesting placing the nonsense tag in between them to break them up, but this did not help. Any suggestions?
Answering my own question in case it helps someone else someday, it appears there needs to be actual renderable content between two successive name tags for the android browser (a comment alone didn't do it). When I added some all worked as intended.

How to select <p> tag of a div tag using JSoup in android

I am developing an application in android in which I am using JSoup to parse data from a website and display it in the activity. I want to select Paragraph tags of a particular div tag because there are so many div tags. This paragraph tags are in a table format. For this I am using this :
document.select("p[style*=margin-left:56.9pt]");
But using this, it is displaying only one paragraph tag. But actually there are 8 to 9 paragraph tags. I want to display all the tags.
Please suggest me how to do this.
Can you share your html page or link to that html page or some snippet. Ideally select method of document tag actually returns an Elements object which is a List implementation underneath. Even though its is just one object, its a List object. Try iterating through it like
for (Element divTag : document.select("p[style*=margin-left:56.9pt]")) {
//Your code
}
That is one possibility. Other than that i suppose your html has only one <p> tag with style attribute set to margin-left:56.9pt. If this didnt help plase share your html code for more information.

Categories

Resources