Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML flickers on Honeycomb landscape

When displaying a WebView in full screen (fill_parent both width and height) in Honeycomb, the HTML flickers an instant when loaded in landscape orientation.

Given this code, you should only see the yellow background (WebView color) or the blue background (html body color). But when switching to landscape, you can see the screen partially filled in blue, and behind yellow.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView webView = (WebView) findViewById(R.id.webview);
    webView.setBackgroundColor(Color.YELLOW);
    webView.loadData("<html><body style='background-color:#DDF'><p>Hello world!!!</p></body></html>", "text/html", "UTF-8");
}

It's like the HTML was rendered before knowing the container size, and then it gets resized.

This can be reproduced in Android Honeycomb in landscape orientation, both in the emulator and a device.

Any ideas?

like image 424
willy Avatar asked Aug 29 '11 16:08

willy


2 Answers

Try disabling hardware acceleration for that activity in the manifest

<activity android:name="com.sample.activity"
 android:hardwareAccelerated="false"/>
like image 138
Fernando Gallego Avatar answered Nov 02 '22 20:11

Fernando Gallego


I realize this post of yours is old but I figure input might still be useful. I don't have an actually honeycomb tablet to test the change of orientation but this should work regardless.

I was extremely perplexed by this, but then I noticed the problem. Simply change style from "background-color" to just "color":

like image 21
thethomasramsey Avatar answered Nov 02 '22 21:11

thethomasramsey