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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:47:03+00:00 2026-05-27T16:47:03+00:00

I have a very simple Activity with the following layout… <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent

  • 0

I have a very simple Activity with the following layout…

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </WebView>
</LinearLayout>

The Activity itself is set for full screen (no title bar and no Android notification bar) and forced to landscape.

So…on my HTC Desire, the WebView in theory is occupying 800×480 (wxh) pixels. All good so far, it DOES fill the screen totally.

The confusion I have is that the WebView loads an HTML document from a server which uses a javascript function to get the screen width and height…

<script type="text/javascript">
<!--
    function getDims() {
        var screenW = screen.width;
        var screenH = screen.height;
        return "size=" + screenW + "x" + screenH;
    };
-->
</script>

…the problem is that screenW is 527 and screenH is 320 and I don’t understand why.

Looking at a height of 320, it’s exactly two-thirds of 480 so I then looked at what two-thirds of 800 is (~533). So it seems both screen.width and screen.height in the javascript are reporting two-thirds of actual pixels available.

Can anyone explain why this is happening?

  • 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-27T16:47:03+00:00Added an answer on May 27, 2026 at 4:47 pm

    For website you can control the screen size in android using a meta tag in your site.

    There are three settings for the “screen” size low-dpi, medium-dpi and high-dpi.

    So the device is automatically scaling your website (it assumes medium-dpi if you didn’t set anything)

    In javascript you don’t get the exact pixel size of the device, you get more like the device is somewhere in that area…

    A good explanation for this can be found here: http://developer.android.com/guide/webapps/targeting.html

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

Sidebar

Related Questions

I have the following View setup in one of my Activities: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/photoLayout
I have a very simple Android activity layout like this: <?xml version=1.0 encoding=utf-8?> <LinearLayout
So I have a very simple android activity that starts a timer when you
I have a very simple Java RMI Server that looks like the following: import
I'm trying to build a very simple VPS control panel; i have the following
Hopefully this is very simple. I have a central activity that can be launched
I have a very simple app for Android that displays a Google Maps view
I have a simple activity with only one edittext which was set to http://
I have the following very simple class which looks for the last known user
I have an application that contains a main Activity, which has a very simple

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.