开发者

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?


Try disabling hardware acceleration for that activity in the manifest

<activity android:name="com.sample.activity"
 android:hardwareAccelerated="false"/>


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":

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜