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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:57:46+00:00 2026-05-23T00:57:46+00:00

I am trying to do the typical thing where you load data into a

  • 0

I am trying to do the typical thing where you load data into a URL string, call google’s chart API with all that date, and then Load it into a Webview.

Question: Does someone have a direct ‘right’ way to do this?

I have been messing with this all night.

Here is the main problem:

The webview is set to Fill_Parent. Meaning I dont really know the exact width and height. Since google’s API requires that you present a width and height, how exactly do I get the webviews width and height so I can send it over? I tried this solution:

final WebView web = (WebView)findViewById(R.id.webviewgraph);
    ViewTreeObserver tree = web.getViewTreeObserver();
    tree.addOnGlobalLayoutListener(new OnGlobalLayoutListener()
    {
        @Override
        public void onGlobalLayout() 
        {...code continues

And things seem to be in order, but when I call web.getWidth(), web.getDrawingBounds(), or web.getMeasuredWidth(), I am always returned MORE than what the screen actually holds. Right now I am solving this issue by subtracting a constant offset of 136 pixels… but alas, this is NOT consistent with all devices.

Does someone know either the “correct” way to use google map API’s with a fluid webview? Or perhaps does someone know how to get the actual correct width and height of a view?

Thanks

UPDATE
I changed my code such that now I am using a custom webview that overrides the OnSizeChanged event. The width and height that are returned are … unfortunately still the same… Just too large.

UPDATE
After analyzing the width and height more, I came up with this:

int w = (int)((float)width * .667f);
int h = (int)((float)height * .667f);

So far this is working on the devices I am testing on. Why would the width and height be returning 1/3 MORE than the actual width? I have no idea.

  • 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-23T00:57:46+00:00Added an answer on May 23, 2026 at 12:57 am

    I haven’t had time to double check this, but I find it highly likely that your 0.667f is related to the fact that the webview is scaled according to the density of your devices.

    According to
    http://developer.android.com/guide/webapps/targeting.html#ViewportDensity
    “the high-density device shows the web page with a default scale factor that is 1.5 times larger than the actual pixel resolution, to match the target density”

    You need to find the target density use and use it as the scale:

    final float scale = getResources().getDisplayMetrics().density;
    
    // Your code:
    int w = (int)(width / scale);
    int h = (int)(height / scale);
    

    I’m not too well read on the subject, but I think that you can prevent the scaling using

    <meta name="viewport" content="target-densitydpi=device-dpi" />
    

    but don’t take my word for it. Also, I’m not sure from which API level the viewport is valid.

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

Sidebar

Related Questions

I am trying to load a html page through UIWebview.I need to disable all
Here is a typical URL I'm trying to rewrite: Example requested URL: http://topleveldomain/search?q=clause1+clause2+clause3&State=FL It
Trying to find some simple SQL Server PIVOT examples. Most of the examples that
Trying to make a make generic select control that I can dynamically add elements
Trying to keep all the presentation stuff in the xhtml on this project and
Trying to make a MySQL-based application support MS SQL, I ran into the following
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
Trying to perform a single boolean NOT operation, it appears that under MS SQL
Trying to honor a feature request from our customers, I'd like that my application,
Hope this doesn't get too complicated. :) thing is.. I'm trying to make my

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.