I did this using code and xml:
<WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="251dp" android:layout_below="@+id/download" android:layout_marginTop="20dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/>
and this (for horizontal center):
WebView loading = (WebView)rootView.findViewById(R.id.webview); loading.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); loading.loadDataWithBaseURL("file:///android_asset/", "<html><center><img src=\"done.png\"></html>", "text/html", "utf-8", "");
Or is it for (horizontal and vertical center):
WebView loading = (WebView)rootView.findViewById(R.id.webview); loading.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); loading.loadDataWithBaseURL("file:///android_asset/", "<html>\n" + "<body bgcolor=\"white\">\n" + " <table width=\"100%\" height=\"100%\">\n" + " <tr>\n" + " <td align=\"center\" valign=\"center\">\n" + " <img src=\"loading.gif\">\n" + " </td>\n" + " </tr>\n" + " </table>\n" + "</body>", "text/html", "utf-8", "");
source share