Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dev-sareno/03659892e0b84c7df6dfc9bb01b68f80 to your computer and use it in GitHub Desktop.
Save dev-sareno/03659892e0b84c7df6dfc9bb01b68f80 to your computer and use it in GitHub Desktop.
Ionic - Android Native - Change text zoom size (Alternative to Ionic Mobile Accessibility)
package com.example.app;

import android.os.Bundle;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import com.getcapacitor.android.R;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
    }});

    ViewGroup rootView = getWindow().getDecorView().findViewById(android.R.id.content);
    WebView webView = rootView.findViewById(R.id.webview);
    
    // TODO: Do something with webView
    WebSettings webSettings = webView.getSettings();

    // Default text zoom is 100 (100%)
    // Set text zoom size 50% bigger
    webSettings.setTextZoom(150);
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment