【发布时间】:2012-03-07 13:10:02
【问题描述】:
在我的 webview 活动中,我可以垂直(上下)滚动网页,但不能水平滚动(从右到左或从左到右),当我也缩放网页时,仍然没有水平滚动。
有没有可能在 webview 中添加这个? 非常感谢。
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.setVerticalScrollBarEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MyActivity.setTitle("Loading...");
MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MyActivity.setTitle(R.string.app_name);
}
});
mWebView.setWebViewClient(new Manipulation());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(myURL);
XML:
<?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/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
【问题讨论】:
-
传统上android中的WebView默认支持水平滚动。也许您以某种方式在代码中禁用了它,或者您没有查看水平滚动的页面?
-
@bbedward: 请看我的代码