我有一个简单的应用程序,它从网络上提取某些图像并通过 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 < Y。启动,尺寸 X 的图像按预期显示,点击按钮,按预期显示尺寸 Y 的图像,如果下一个图像尺寸为,则点击按钮X 再次显示,它会以额外的空白(总是在下方)填充到 Y 大小。对于许多大小为 X 的图像,它可能会保持这种状态,或者随机恢复正常。希望我把问题说清楚了。
我是否必须以某种方式明确重置界限?我做了相当多的谷歌搜索,但找不到问题。
提前致谢!