 <p>i use LinearLayout to show webview and setGravity.</p> <pre><code> LinearLayout linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); linearLayout.setGravity(Gravity.CENTER); WebView view = new WebView(this); linearLayout.addView(view); setContentView(linearLayout); </code></pre> <p>it help you.</p>