Is it possible to add zoom to mobile targeted website?
I use webview and I need that mobile website’s text is bigger and I think this can be solution if I’m able to zoom in. But Web.getSettings().setBuiltInZoomControls(true);is not working. It doesn’t allow me to zoom.
Edit:
Here is what I have now:
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());
Edit2:
This is how I tried Mocialov Boris’s answer:
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);
In this solution it is important to have implemented handler, because it will do changes to your UI from some thread. You said that app was crashing after you added this
mContentView.addView(zoom);line, I assume that that was the problem