Android的web视图 - 底部空白空格扩展到设备后宽 [英] Android Webview - Empty white space at the bottom after scaling to the device width
问题描述
我缩放我的WebView使用以下code,以适应内容到屏幕的宽度:
webView.getSettings()setLoadWithOverviewMode(真)。
。webView.getSettings()setUseWideViewPort(真);
。webView.getSettings()setBuiltInZoomControls(真);
这工作,但现在我得到的内容底部的空白处。空的空间的大小(高度)成正比它做变焦的幅度。因此,对于较小的设备,其大小更大。
我的感觉是变焦生效后不重新计算滚动条大小。这个假设是由于通过点击屏幕上放大和退房时,空白空间消失的事实。虽然这是工作在Android 2.3而不是4.0上。
我的问题是如何使滚动缩放后重新计算。或者有没有其他的解决方案。
感谢。
P.S。这里是我在XML定义的WebView
<?XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
>< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直
机器人:背景=#FFFFFF> <的WebView
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / web_view
机器人:背景=#AAFFFFFF
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT/>< / LinearLayout中>
< /滚动型>
为什么你有一个滚动视图内的LinearLayout内的web视图,首先?网页视图从滚动视图继承并实现它自己的滚动,那么什么是其他的滚动视图?从本质上讲,你将有一个卷轴内的卷轴!其次我也看到你有WRAP_CONTENT
为您的WebView的android:layout_height
属性
I am scaling my webview to fit the content to the width of the screen using the following code:
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
This works but now I am getting an empty space at the bottom of the content. The size (in height) of the empty space is directly proportional to the magnitude of the zoom it is doing. So for smaller devices, the size is greater.
My feeling is that scroll bars size are not being recalculated after the zoom has taken effect. This assumption is due to the fact that when zooming-in and out by tapping on the screen, empty space goes away. Although this is working on Android 2.3 but not on 4.0.
My question how to force the scrollbars to recalculate after the zoom. Or is there any other solution.
Thanks.
P.S. Here is how I defined the webview in xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/web_view"
android:background="#AAFFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Why do you have a webview within a linearlayout within a scrollview, first of all? A WebView inherits from scrollView and implements it's own scrolling, so what is the other scrollview for? Essentially you will have a scroller within a scroller!!! Secondly I do see that you have "wrap_content"
for your WebView' android:layout_height
property.
这篇关于Android的web视图 - 底部空白空格扩展到设备后宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!