views:

66

answers:

1

I am getting some HTML text from a remote server which I am displaying inside a WebView. I need to format the text display and set a font size and color for the WebView.

The only way I can think of is: pre-pending the HTML string received with a tag and specify the font information there.

What is the correct way to do this?

+1  A: 

CSS stylesheet? Assuming you know what the requested HTML content will look like; which you should since you can retrieve it and look at it.

Or am I misunderstanding the question?

Pierre-Antoine LaFayette
The HTML I receive contains text, images and hyperlinks and I know how the content looks like. My problem is how do I set style information in a WebView? The only thing, I can think of is prepending a <div> tag and adding style attributes to it. How do I setup a WebView with CSS in Android?
Samuh
Prepend a link tag with your css file. E.g. <link rel="stylesheet" type="text/css" href="theme.css" />.
Pierre-Antoine LaFayette
Is there a tutorial for this? How do I set CSS info in a WebView?
Samuh
I'm not talking about changing the WebView, I'm talking about adding a stylesheet to the HTML content that will be rendered by the WebView. The way I'm understanding your question, it seems that this should be a reasonable solution.
Pierre-Antoine LaFayette
I agree that having all the style information in a CSS file and liking it with the HTML that I receive would be neat(+1 for that). I am not sure of where I should create and put this CSS file though? Looks like, I need to do some more googling.Anyways, thanks for your time and help. Appreciate it.
Samuh
I finally did this by prepending some tags with style information.Had to use WebView.loadDataWithBaseURL() variant of the method supplying some fake URLs to make it work correctly though.Thanks.
Samuh