WebView Rending 100% wide HTML

by Brian » Sat, 27 Mar 2010 03:55:39 GMT

Sponsored Links
 I am working on an app that has a WebView that contains 5 pages. When
the webview page is first loaded, everything displays fine, but as
soon as you click Next on the first page everything shrinks down, as
if the webview window size has collapsed. Then when you click back to
the first page, it is collapsed as well, even though it displayed fine
when the window first opened.

I am thinking somehow the webview is changing size because the color
is just white surrounding my smashed page, even though the background
color of the page is dark.

This only happens when the content is set to be 100% wide in the HTML,
if I set a pixel width it maintains the size, but I need it to scale
for the different android phones.

Any thoughts / ideas?


WebView Rending 100% wide HTML

by Joe Bowser » Wed, 31 Mar 2010 02:37:03 GMT

 Have you tried setting the Initial Scale to 100%, and setting the
Layout Algorithm to normal?  A code example is below (assume appView
is a WebView):

        WebSettings settings = appView.getSettings();

Also, if you use the viewport tag in your header, it will scale it to
the resolution:
<meta name="viewport" content="width=320; user-scalable=no" />

I prefer NOT using the viewport meta tag, and actually using HTML and
CSS relative values for HTML-based UI whenever possible.  Setting the
Layout Algorithm is essential if you want your CSS to actually work
properly so that 100px is really 100px.


Sponsored Links

Other Threads

1. Bluetooth for magic

Mohon bantuan ada gak aplikasi  bluetooth yg bs ngirim image dan sound untuk
magic, makasih

Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group:


2. Using FLAG_ACTIVITY_CLEAR_TOP, but don't restart target activity?

Per the documentation:

"The currently running instance of activity B in the above example will
either receive the new intent you are starting here in its onNewIntent()
method, or be itself finished and restarted with the new intent. If it
has declared its launch mode to be "multiple" (the default) and you have
not set FLAG_ACTIVITY_SINGLE_TOP in the same intent, then it will be
finished and re-created; for all other launch modes or if
FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be delivered to
the current instance's onNewIntent(). "


So, try OR'ing FLAG_ACTIVITY_SINGLE_TOP in your Intent that you're using
with FLAG_ACTIVITY_CLEAR_TOP, and see if that does the trick.

Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Consulting/App Development: http://commonsware.com/consulting


3. Using FLAG_ACTIVITY_CLEAR_TOP, but don't restart target activity?

4. using gdb in Android x86

5. namespace in styles.xml

6. Abridged summary of android-developers@googlegroups.com - 27 Messages in 11 Topics

7. Seesmic Now Available for Android & Blackberry