【发布时间】:2012-01-01 16:39:20
【问题描述】:
我已经开始使用 WebView 开发应用程序。实际上,我正在使用 Webview 加载图像(我喜欢使用该类的内置缩放控件)。我可以成功加载图像,但我可以看到一些恼人的空白。我找不到删除它的方法。我的图像大小为 750 * 1000。我在下面附上了我的代码。
webview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
ImageViewer.java
package com.android.test;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class ImageViewer extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
String loadUrl = "file:///android_res/drawable/splash_001.jpg";
WebView image = (WebView) findViewById(R.id.webView);
image.clearView();
image.clearCache(true);
image.getSettings().setBuiltInZoomControls(true);
image.getSettings().setSupportZoom(true);
image.getSettings().setLoadWithOverviewMode(true);
image.getSettings().setUseWideViewPort(true);
image.loadUrl(loadUrl);
}
}
【问题讨论】:
-
您用于测试的手机/标签的尺寸是多少?
-
尝试将您的 layout_xx 更改为 'fill parent'
-
嗨。你有什么解决方案吗?我在这里遇到了同样的问题。你能帮帮我吗
标签: android image android-webview padding space