user1026605
user1026605

Reputation: 1430

Android: how to format a html string to be displayed in a webview?

Here is why I want to do. I have an html string extracted from a rss feed. I want it to display nicely in a WebView embedded in my activity. I can easily do it using the loadData() function, but the display isn't optimized for a small device : in another word I want to resize the html content not to exceed my view width. So images, frames, tables need to be resized.

How can I do it ? I thought I could use Google Wireless Transcoder service but it only works with urls

Upvotes: 0

Views: 605

Answers (1)

FunkTheMonk
FunkTheMonk

Reputation: 10938

One option would be to use css, but it depends on the feed (each post might have different formatting / apply styles inline) Use loadDataWithBaseURL(), with "file:///android_asset/" as the base url. Put a css file in your /project/assets folder. Inject the css file into the tag of your html.

Upvotes: 1

Related Questions