我想在web视图上把图像加载到中间,但图像显示在web视图的左上角。图像是网络的,而不是当地的。
gifView.loadUrl(mImageUrl);
gifView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
view.getSettings().setLoadsImagesAutomatically(true);
if (mProgressBar != null) {
mProgressBar.setVisibility(View.GONE);
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (mProgressBar != null) {
mProgressBar.setVisibility(View.VISIBLE);
}
}
});
<WebView
android:id="@+id/gif_image"
android:background="@null"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
还添加了:
String HTML_FORMAT = "<html><body style=\"text-align: center; background-color: null; vertical-align: middle;\"><img src = \"%s\" /></body></html>";
final String html = String.format(HTML_FORMAT, mImageUrl);
gifView.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
我使用上面的代码,怎么把图像加载到视图的中间呢?