Android Webview中图像下的额外空白

时间:2011-12-15 16:59:42

标签: android android-webview removing-whitespace

我有一个简单的应用程序,可以将某些图像从网络中提取出来并通过WebView显示它们,下面有按钮和上面的标题。起初,我遇到了一个问题,即在图像下不断有额外的空白,现在已经解决了。

作为参考,WebView定义如下:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/c"
    android:layout_above="@id/b"
    android:layout_below="@id/t"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <WebView 
        android:id="@+id/webview"
        android:scaleType="centerInside"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:adjustViewBounds="true" />

</RelativeLayout>

这个相对布局是另一个,我把它留了出来。 在活动中我有以下内容:

        WebView img = (WebView) findViewById(R.id.webview);
        img.getSettings().setBuiltInZoomControls(true);
        img.getSettings().setSupportZoom(false);
        img.loadUrl(image);

现在到了当前的问题:

我正在拉动和观看的图像有不同的尺寸。为简单起见,让我们谈谈两种尺寸 - X和Y,X&lt; Y.启动,尺寸X的图像按预期显示,按钮点按,尺寸Y的图像按预期显示,按钮点击,如果下一幅图像的尺寸为X,则将显示额外的空白(总是在下面)填充它大小为Y.对于大量X的大量图像或随机恢复正常,它可能保持这种状态。希望我明白这个问题。

我是否必须以某种方式明确重置边界?我公平地分享了谷歌搜索,但找不到捕获。

提前致谢!

0 个答案:

没有答案