我在我的活动中包含了一个WebView,并在其中加载了一些Javascript,然后从外部网站获取数据。 这工作并显示正常,但问题是我的活动不会在WebView完成加载时滚动,所以我看不到WebView的底部,例如我在其下面放置的所有其他视图。知道如何处理这个问题吗? 欢呼声。
答案 0 :(得分:1)
你在布局中使用scrollview吗?试试看,看看是否有帮助。
以下是指向开发者page
的链接答案 1 :(得分:0)
这样可以正常显示,但问题是当WebView完成加载时我的活动不会滚动,所以我看不到WebView的底部,比如我在其下面放置的所有其他视图。
您需要更改布局,以便“我在其下方放置的其他视图”将显示在屏幕上,而WebView
只占用剩余空间。
例如,这是一个显示WebView
Button
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
/>
<Button android:id="@+id/helpcast"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="View Helpcast"
/>
</LinearLayout>
由于WebView
的设置高度为0px
但权重为1
,并且因为Button
未指定权重,WebView
将填写Button
在屏幕上后留下的所有空格。如果需要,WebView
内容将根据您在其中加载的任何网页在WebView
内部滚动。