title: Android: Loading AMP Formatted HTML into a WebView
body: <p>I'm retrieving Accelerated Mobile Pages (APM) formatted HTML form a webcall. I'm then trying to display that AMP in a WebView. So I'm setting up my WebView like this:</p>
  
  <pre><code>webView = (WebView) findViewById(R.id.web_view);
  webView.setWebChromeClient(new WebChromeClient());
  webView.getSettings().setJavaScriptEnabled(true);
  String content = article.getContentAmp();
  webView.loadData(content, "text/html; charset=utf-8", null);
  </code></pre>
  
  <p>It displays content without error, but it's not displaying correctly. It ignores for example amp-youtube elements and embeded tweets.</p>
  
  <p>Is there something else I have to do with the WebView or the WebChromeClient to display AMP correctly?</p>
  
  <p>EDIT:</p>
  
  <p>The answer below works. But in my specific case, I was using the WebView inside a NestedScrollView. Which worked fine in Android 5.0+, but below that, the amp- elements would not load.</p>
  
  <p>Taking the WebView out of the NestedScrollView solved the problem. It's parent is now a relative layout.</p>
  
  <p>So if you're having the same problem, try simplifying your layout so that the WebView is not deeply nested. And definitely don't put your WebView inside a NestedScrollView.</p>