-1

How to zoom in/out browser programmatically (not a webview)? Or maybe it is impossible to do that ?

For a PC I can do it by pressing Ctrl and + , but how to do it in Android?

I speak about android browsers (like a Google Chrome), not about WebView.

Blauharley
  • 3,936
  • 6
  • 25
  • 45
abrutsze
  • 446
  • 1
  • 6
  • 20
  • 1
    Possible duplicate of [Set zoom for Webview](https://stackoverflow.com/questions/2505393/set-zoom-for-webview) – petey Dec 19 '17 at 15:54
  • I wouldn't consider using the `CTRL`+`+` [hotkey](https://en.wikipedia.org/wiki/Keyboard_shortcut) a "programmatic" approach... unless you are trying to use said hotkey through code (which seems very unreliable). – Bryan Dec 19 '17 at 15:55
  • petey, it is not a duplicate of that question, since in that question they are speaking about WebView but I mentioned a default Android browser. – abrutsze Dec 19 '17 at 15:56
  • Bryan, do you have any idea how to organize that zoom process ? – abrutsze Dec 19 '17 at 15:56
  • What do you mean by "organize"? Are you attempting to write any code? If so, post what you have. – Bryan Dec 19 '17 at 15:59
  • The problem is that I have tried the following but it does not work: mKey = new Key(RemoteIME.mService, event.getAction(), KeyEvent.META_CTRL_ON & KeyEvent.KEYCODE_PLUS); – abrutsze Dec 19 '17 at 16:02
  • 2
    This is impractical. First, you cannot control other apps, except through specific capabilities (e.g., acceessibility services) that place security and distribution limitations on your app. Second, there are dozens, if not hundreds, of Web browsers for Android. None of them necessarily have to offer a zoom option that could be controlled through an accessibility service. – CommonsWare Dec 19 '17 at 16:03
  • 1
    I know that Google Chrome offers that possibility, but do not have any idea how to make it true – abrutsze Dec 19 '17 at 16:05
  • If you are trying to make it for Chrome specifically, the `CTRL`+`+` hotkey is not recognized on Android. [From what I could find](https://www.pcworld.com/article/184656/android_keyboard_shortcuts.html), Chrome recognizes `MENU`+`I` to zoom in. Though, as I mentioned before, this seems very unreliable; not all browsers will recognize the same hotkey, and Google could decide to change this functionality in Chrome at any time. – Bryan Dec 19 '17 at 16:10
  • Yes google chrome offers some customisation check out my answer. – gautam Dec 19 '17 at 16:11

2 Answers2

0

No you cannot do that in default android browsers as you have no control over them programatically but by using custom tabs you can achieve some customisation, check out this site:-

https://developer.chrome.com/multidevice/android/customtabs

gautam
  • 1,371
  • 2
  • 13
  • 32
0

It seems strange but for zoom in/ out are responsible KeyEvent.KEYCODE_MEDIA_REWIND / KEYCODE_MEDIA_FAST_FORWARD. However, that worked for me in Google Chrome ( I have not tried in other browsers ).

abrutsze
  • 446
  • 1
  • 6
  • 20