gpt4 book ai didi

android - 在 webview 中启用水平滚动

转载 作者:可可西里 更新时间:2023-11-01 18:45:17 24 4
gpt4 key购买 nike

在我的 webview Activity 中,我可以垂直(上下)滚动网页,但我不能水平滚动(从右到左或从左到右),当我也缩放网页时,仍然没有水平滚动。

有没有可能在 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>

最佳答案

简答:

使用这个

mWebView.getSettings().setUseWideViewPort(true);

长答案:

这可能是由于以下任何因素造成的

setLoadWithOverviewMode(true) 加载完全缩小的 WebView

setUseWideViewPort(true) 使 Webview 有一个正常的视口(viewport)(比如一个普通的桌面浏览器),而当 false 时,webview 将有一个视口(viewport)限制在它自己的尺寸上(所以如果 webview 是50px*50px 视口(viewport)大小相同)

Webview.setInitialScale(xx);

关于android - 在 webview 中启用水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9602124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com