gpt4 book ai didi

android - 放大移动网站和网页 View

转载 作者:行者123 更新时间:2023-11-30 04:26:34 24 4
gpt4 key购买 nike

是否可以向移动目标网站添加缩放功能?

我使用 webview,我需要移动网站的文本更大,我认为如果我能够放大,这可能是一个解决方案。但是 Web.getSettings().setBuiltInZoomControls(true);不管用。它不允许我缩放。

编辑:这是我现在拥有的:

    Web = (WebView) findViewById(R.id.webView1);
Web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
Web.getSettings().setJavaScriptEnabled(true);
Web.getSettings().setBuiltInZoomControls(true);
Web.getSettings().setPluginsEnabled(true);
Web.getSettings().setAllowFileAccess(true);
Web.loadUrl(URL);
Web.getSettings().setCacheMode( WebSettings.LOAD_NO_CACHE );
Web.getSettings().setRenderPriority( RenderPriority.HIGH );
Web.setWebViewClient(new WebViewClient());
Web.setWebViewClient(new ErrorWebViewClient());

编辑2:这就是我尝试 Mocialov Boris 的答案的方式:

View zoom;  
FrameLayout mContentView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web);

Web = (WebView) findViewById(R.id.webView1);
Web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
Web.getSettings().setJavaScriptEnabled(true);
Web.getSettings().setPluginsEnabled(true);
Web.getSettings().setAllowFileAccess(true);
Web.loadUrl(URL);
Web.getSettings().setSupportZoom(true);
Web.getSettings().setCacheMode( WebSettings.LOAD_NO_CACHE );
Web.getSettings().setRenderPriority( RenderPriority.HIGH );
Web.setWebViewClient(new WebViewClient());
Web.setWebViewClient(new ErrorWebViewClient());

mContentView = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
zoom = Web.getZoomControls();
mContentView.addView(zoom);
zoom.setVisibility(View.GONE);

最佳答案

在此解决方案中,实现处理程序很重要,因为它会从某个线程对您的 UI 进行更改。你说应用程序在添加此 mContentView.addView(zoom); 行后崩溃,我认为这就是问题所在

View zoom;  
FrameLayout mContentView;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web);

Web = (WebView) findViewById(R.id.webView1);
Web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
Web.getSettings().setJavaScriptEnabled(true);
Web.getSettings().setPluginsEnabled(true);
Web.getSettings().setAllowFileAccess(true);
Web.loadUrl(URL);
Web.getSettings().setSupportZoom(true);
Web.getSettings().setCacheMode( WebSettings.LOAD_NO_CACHE );
Web.getSettings().setRenderPriority( RenderPriority.HIGH );
Web.setWebViewClient(new WebViewClient());
Web.setWebViewClient(new ErrorWebViewClient());

mContentView = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
zoom = Web.getZoomControls();
mContentView.addView(zoom);
zoom.setVisibility(View.GONE);
}

private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
System.out.println("got msg");
switch (msg.what) {
case 0:
mContentView.addView(zoom);
break;
}
}
}

关于android - 放大移动网站和网页 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8379787/

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