I am trying to create a WebView dynamically using the following code:
mWebView = new WebView(this);
mWebView.setId(R.id.webview);
mWebView.setVerticalScrollBarEn
Old question, but answering anyway incase someone else finds it:
You can call setLayerType via reflection. That way the code will run independent of OS version.
try {
Method setLayerTypeMethod = mWebView.getClass().getMethod("setLayerType", new Class[] {int.class, Paint.class});
setLayerTypeMethod.invoke(mWebView, new Object[] {LAYER_TYPE_SOFTWARE, null});
} catch (NoSuchMethodException e) {
// Older OS, no HW acceleration anyway
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}