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 7636179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:36:30+00:00 2026-05-31T07:36:30+00:00

In a webview on Android, I load an html file that contains an HTML5

  • 0

In a webview on Android, I load an html file that contains an HTML5 canvas. When writing text to the canvas, it is extremely small. If I load the same html file in a PC browser or even a web view on IOS, it looks correct. As far as I can tell, I have disabled zooming, and the canvas is filling the entire web view. I would expect the font size to be the same as when loaded in other browsers. Any ideas?

In the head of the html file, the viewport is declared as:

<meta name='viewport' content='target-densitydpi=device-dpi,initial-scale=1.0,user-scalable=no'/>

in the body of the html file, the canvas is declared as:

<canvas id='rtmc_canvas' style='position:relative; left:0px; top:0px;'/>

after the page is loaded, I dynamically adjust the canvas to fill the screen.

  • 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-31T07:36:31+00:00Added an answer on May 31, 2026 at 7:36 am

    You set the density to 1.0 and tell Android’s WebView not to scale anything at all when you declared your viewport in that specific way. You can either remove that viewport declaration, which will then cause images to be scaled as well as fonts or you can modify the text size settings of the WebView based on the Android device that the user is running your application on. I’ll assume you want to do the latter.

    You’ll need to first calculate the density of the device. You can do that with this piece of code:

    float density = getResources().getDisplayMetrics().density;
    

    Then you can adjust the font size for the density.

    If density is 1.0, then it is medium density (mdpi), >= 1.5 is high density (hdpi) and >= 2.0 is extra high density (xhdpi).

    If you are using ICS, then it has a nice API for WebView:

    webView.getSettings().setTextZoom(100 * density);
    

    If you are using a pre-ICS device, then you have to use an if/else statement to check for the densities above and then use:

    if (density < 1.5) {
        // mdpi:
        webView.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
    } else if ((density >= 1.5) && (density < 2.0)) {
        // hdpi:
        webView.getSettings().setTextSize(WebSettings.TextSize.LARGER);
    } else {
        // xhdpi:
        webView.getSettings().setTextSize(WebSettings.TextSize.LARGEST);
    }
    

    Or better yet, you can wrap both of those in an if ICS/else pre-ICS by checking Build.VERSION.SDK_INT.

    Here is some further reading about density: http://developer.android.com/guide/practices/screens_support.html

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

Sidebar

Related Questions

In android app, I need to dynamically generate html and load that into webview
I've got a native Android app that contains a WebView. All my HTML, js
I'm trying to do a simple application that will load a local html file
I have a WebView. I want to load a local HTML file called helloworld.html.
I have been trying to load a html file in a webview in a
I have a simple webview used to load a file help3.html when a user
I want to load a local jqmobile html file into a webview. I am
I created a native Android app that basically hosts a webView control. That webView
I'm building an Android application that's based around an enhanced WebView (based on PhoneGap).
I have an Android application that is a TabHost with a WebView. I use

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.