Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396272
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:23:16+00:00 2026-05-18T04:23:16+00:00

How do you adjust the font size of an Android WebView ? The following

  • 0

How do you adjust the font size of an Android WebView? The following appears to have no effect:

private void fontSizePlus() {
    fontSize = (fontSize < FONT_SIZE_MAX) ? fontSize + FONT_SIZE_INCREMENT : fontSize;
    this.changeFontSize(fontSize);
}

private void fontSizeMinus() {
    fontSize = (fontSize > FONT_SIZE_MIN) ? fontSize - FONT_SIZE_INCREMENT : fontSize;
    this.changeFontSize(fontSize);
}

private void changeFontSize(int value) {
    String js = "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '" + value + "%';";
    mWebView.loadUrl("javascript:(function() { " + js +  " })()");  
}

Where the WebView and constants have been initialized as follows:

private final static int FONT_SIZE_DEFAULT = 100;
private final static int FONT_SIZE_MIN = 50;
private final static int FONT_SIZE_MAX = 150;
private final static int FONT_SIZE_INCREMENT = 5;
private int fontSize = FONT_SIZE_DEFAULT;

private WebView mWebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.index);
    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("file:///android_asset/index.htm");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:23:17+00:00Added an answer on May 18, 2026 at 4:23 am

    @rob’s answer and comment pointed me in the right direction.

    First make sure that all font sizes are relative to the default font size. If you use absolute values the following will not work on those elements.

    Then:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        mWebView = (WebView) findViewById(R.id.webview);
        fontSize = mWebView.getSettings().getDefaultFontSize();
        ...
    }
    
    private void fontSizePlus() {
        fontSize++;
        this.changeFontSize(fontSize);
    }
    
    private void fontSizeMinus() {
        fontSize--;
        this.changeFontSize(fontSize);
    }
    
    private void changeFontSize(int value) {
        mWebView.getSettings().setDefaultFontSize(value);
    }
    

    By changing the value of the default font size all relative font sizes are adjusted accordingly. This gives you much greater control than WebSettings.setTextSize (WebSettings.TextSize t).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multiline UILabel whose font size I'd like to adjust depending on
The scenario is trying to adjust font size to get a nice graphic arrangement,
When myLabel.adjustsFontSizeToFitWidth = YES , UILabel will adjust the font size automatically in case
Is it possible to adjust the size/font of the TogglerBar, so that they are
I'm using a twitter feed control and I'm trying to adjust the font size
I'm trying to adjust a jquery script to my needs and encountered the following
I have the following code: <div id=container> <div id=top>TOP TEXT </div> <div id=middle>MIDDLE TEXT
I'm wanting to keep the font size of a navigation menu the same size
* { margin: 0; border: 0; padding: 0; } html { -webkit-text-size-adjust: none; }
How do you increase/decrease the font size in a web page when you don't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.