title: Programmatically align the webview to center of LinearLayout
body: <p>I have a LinearLayout in the xml and now I am adding the webview to that LinearLayout but the webview is displaying on top its not aligning in the center.</p>
  
  <p>this is how its displaying now.</p>
  
  <pre><code>webview content
  --------------------
  webview content
  --------------------
  webview content
  --------------------
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>        WebView answerHtml = new WebView(this);
          answerHtml.setId(i);
          answerHtml.setOnTouchListener(AnswerListener);
          answerHtml.setBackgroundColor(0);
          answerHtml.setBackgroundResource(R.drawable.ans_back);
          answerHtml.getSettings().setJavaScriptEnabled(true);
          answerHtml.loadDataWithBaseURL(null, a.getText(), "text/html", "utf-8", null);
          ansCellLayout.addView(answerHtml,new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,80));
          ansCellLayout is a Linearlayout  defined in xml.
  </code></pre>
  
  <p><strong>SOLVED</strong></p>
  
  <pre><code>answerHtml.loadDataWithBaseURL(null,"&lt;html&gt;&lt;head&gt;&lt;style type='text/css'&gt;html,body {margin: 0;padding: 0;width: 100%;height: 100%;}html {display: table;}body {display: table-cell;vertical-align: middle;text-align: center;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;"+a.getText()+"&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", "text/html", "utf-8", null);
  </code></pre>
  
  <p>Now its vertically centered to the layout.</p>