HTML flickers on a cellular landscape

When the WebView is fully displayed ( fill_parent and width and height) in Honeycomb, HTML, it blinks instantly when loaded in a horizontal orientation.

Given this code, you should see only a yellow background ( WebView color) or blue background (html body color). But when you switch to landscape, you can see that the screen is partially filled with blue, and the back is 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 is like HTML was rendered before it knew the size of the container and then it would be resized.

This can be played in Android Honeycomb in landscape orientation, both in the emulator and on the device.

Any ideas?

+6
source share
2 answers

Try disabling hardware acceleration for this activity in the manifest.

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

I understand that you have an old position, but I think that entry can be useful. I don't actually have a cellular tablet to check for a change in orientation, but this should work independently.

I was very puzzled by this, but then I noticed a problem. Just change the style from "background-color" to "color":

+1
source

Source: https://habr.com/ru/post/896138/


All Articles