title: Android setLayerType Webview
body: <p>I am trying to create a WebView dynamically using the following code:</p>
  
  <pre><code>mWebView = new WebView(this);
  mWebView.setId(R.id.webview);
  mWebView.setVerticalScrollBarEnabled(false);
  
  mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
  
  mWebView.setHorizontalScrollBarEnabled(false);
  mWebView.setWebViewClient(mWebViewClient);
  mWebView.setWebChromeClient(mWebChromeClient);
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
  </code></pre>
  
  <p>But, when I run the program, my app force quits stating an error that there is no such method as 'setLayerType'. However, when I create the Webview via the xml, there seems to be no problem:</p>
  
  <pre><code>&lt;WebView android:id="@+id/webview"
      android:scrollbars="none"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layerType="software" /&gt;
  </code></pre>
  
  <p>I use the 'layertype' attribute here and the app runs fine. Can somebody please explain the discrepancy? Is there no way to set the layer type of a WebView dynamically?</p>