【发布时间】:2014-01-03 18:31:06
【问题描述】:
我的 Android WebView 无法滚动。
XML 代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#87cefa"
android:gravity="left"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true" />
我使用正常的webview.loadUrl(url); 函数加载网站,有时使用webview.loadDataWithBaseURL("", htmlContent, "text/html", "UTF-8", ""); 函数,它们都显示页面,但它们不可滚动
初始化:
setContentView(R.layout.activity_main);
webview = (WebView)this.findViewById(R.id.webView);
webview.setVerticalScrollBarEnabled(true);
webview.setHorizontalScrollBarEnabled(true);
加载中:
webview.loadUrl(url);
[either one of them or the other]
webview.loadDataWithBaseURL("", htmlContent, "text/html", "UTF-8", "");
【问题讨论】:
-
也许将 ScrollView 添加为其父级?
-
将webView放入线性布局并设置方向为垂直,将启用滚动。
-
Android WebView Scrollable 的可能重复项
-
他们都没有帮助:(
标签: java android webview scroll