-2

Strange flickering with WebView after setting android:hardwareAccelerated="true" and mWebView.setBackgroundColor(Color.TRANSPARENT)

A no one, no flicker.

Raghunandan
  • 132,755
  • 26
  • 225
  • 256

2 Answers2

0

I have enabled the hardware acceleration for the application and have disabled it for the activity. Additionally I set the background to "null", as mentioned above. It works for me now. Another approach (untested): set the layer type to software rendering and set the background to Color.TRANSPARENT (or "0"): webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
KOTIOS
  • 11,177
  • 3
  • 39
  • 66
0

Do not hard code the flag in code, it is not a best practice! you can enable the function in four levels。

Window level:

getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

View Level:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Activity Level:

<application android:hardwareAccelerated="true">
    <activity ... />
    <activity android:hardwareAccelerated="false" />
</application>

Applecation Level:

<application android:hardwareAccelerated="true" ...>

ref http://developer.android.com/guide/topics/graphics/hardware-accel.html

hoot
  • 1,215
  • 14
  • 15