我是Android新手。我已經開始使用WebView開發一個應用程序。其實我用Webview加載圖像(我喜歡使用類的內置縮放控件)。我可以成功加載圖像,但我可以看到一些惱人的白色空間。我找不到將其刪除的方法。我的圖像尺寸爲750 * 1000。我已附上我的代碼如下,任何幫助將不勝感激!在WebView中刪除不需要的空白Android
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);
}
}
請幫助我!
您用於測試的手機/選項卡的尺寸是多少? – 2012-01-01 17:17:32
嘗試將您的layout_xx更改爲「填充父項」 – Ghost 2012-01-02 05:15:11
嗨。你有沒有解決這個問題。我在這裏遇到了同樣的問題。你能幫我嗎 – 2012-01-05 06:21:42