gpt4 book ai didi

java - 设置WebView大小

转载 作者:太空宇宙 更新时间:2023-11-04 15:22:56 27 4
gpt4 key购买 nike

由于平移/缩放,我正在使用 WebView。在该 WebView 中,我动态添加一些 View 。效果很好, View 按需要显示,但是当我放大 webView 时, View 的大小仍然相同。

使用 WebView 调整它们大小的最佳方法是什么?

而且我还想设置内部 WebView 大小,这样就可以缩小更多。

编辑

我添加这样的 View :

   View iv = inflater.inflate( R.layout.motor_block, null );
WebView wv = (WebView) findViewById(R.id.webView1);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setBuiltInZoomControls(true);
WebSettings settings = wv.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
iv.setTag(currentKey);
wv.addView(iv);

最佳答案

您已经完成了 webView 中需要设置的所有内容。就缩放而言,您只能缩放布局内 webView 的指定大小。因此,您可能需要更改 layout/webview 的高度和宽度,这可能会有所帮助。

或者试试这个:

webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

关于java - 设置WebView大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20222637/

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