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

The Archive Base Latest Questions

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

My application is a simple WebView wrapper that displays a web page in a

  • 0

My application is a simple WebView “wrapper” that displays a web page in a fixed landscape orientation, the page has a centered div that is 760px wide and 415px high and this should be displayed scaled on all devices so it (roughly) fits the screen, the user cannot change the scaling… I’ve almost got everything working apart from the scaling.

I have the following viewport meta tag on the page :

<meta name="viewport" content="width=device-width, target-densityDpi=device-dpi, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

The manifest for the WebView wrapper .apk I’ve created is as follows:

<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name="{my name}"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I should mention that originally the .apk target was Android 2.2 and I’ve recently changed up to 2.3.1 and added another line to the manifest but that’s made no difference to anything :

android:xlargeScreens="true"

I added the following in to the .java code :

webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);
webview.getSettings().setSupportZoom(false);
webview.getSettings().setBuiltInZoomControls(false);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

For the purpose of this question just assume that the only content on the entire site is the following <div>:

<div style="margin: auto; position:relative; align:center; top:0px; width:760px; height:415px; background-color:#000000">

My problem is I can’t to come up with a “one-size-fits-all” scaling solution across all Android devices, everything else I’ve tasked myself with delivering works fine.

I’ve tried this on three different devices, one tablet and two phones, and there is a large gap on the left, right and bottom of the <div> layer. It looks like the 760px width has about another 50px gap on either side and the same underneath on each of the devices, all I want to do is scale that up so it roughly fills the screen on all of the devices.

My phone says it’s got a window.innerWidth of 854 with a window.devicePixelRatio of 1.5 and if I change the initial and maximum scale to 1.12 the <div> layer fits just about perfectly on my device. The table says it’s got a window.innerWidth of 980 with a window.devicePixelRatio of 1.0 and seems to like a scale of around 1.27. I don’t know the details of the third device but using 1.1 seem to do the trick on that.

Of course changing the initial scaling isn’t a solution and even attempting it would be a complete nightmare so, fingers crossed, can anyone tell me the blindingly obvious thing that I’m missing that’ll make this work? Or am I just asking the impossible to automatically scale the view to a fixed size <div>?

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

    Right… On the way home I was stuck in a jam and had a jolly good think, I came to the conclusion that I was dramatically over-thinking this problem.

    This is rough but it does the job, I removed the meta tag from the site and added this to the application :

    // Set up up the scaling value
    float scaling = 100;
    int display_width;
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    display_width = dm.widthPixels;
    scaling = (((float)display_width/760)*100); // 760 here is my container div width
    scaling = (int) Math.floor(scaling); 
    // Set up the webview and apply the scale value
    webview = (WebView) findViewById(R.id.webview);
    webview.setInitialScale((int)scaling);  
    

    That works quite well but I have encountered two issues since I made this post.

    The first is that by removing the meta tag I seem to have removed my limitation on the maximum/minimum scale, this means that clicking on any <INPUT> element which displays the Android keyboard will result in a change in the scaling. Luckily, adding this line to the code solves this issue so far :

    webview.getSettings().setDefaultZoom(ZoomDensity.FAR);
    

    The second I don’t have a workable solution for and is that some devices, such as the Archos101 tablet, have software buttons instead of hardware buttons. The scaling code here will scale to the device width and that means the site goes underneath the software buttons… Currently thinking about implementing a solution based on READ_PHONE_STATE or optionally adding the ability to quit the application without hardware buttons and adding this to the manifest :

    <uses-permission android:name="archos.permission.FULLSCREEN.FULL" />
    

    Hopefully someone else will find this and save themselves some time.

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

Sidebar

Related Questions

I have a simple application written in C# and .Net 2.0 that displays several
I have a simple javaFX application that loads a webpage in a WebView componant.
I have a simple webview which loads a page. This page has a few
I'm developing an Android application that uses a WebView to display the login page
I want to create a simple web based application on Android that loads certain
I need a simple application, preferably a cross-platform one, that enables sending of files
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we
I have a simple application that loads an unmanaged dll and passes a few
I've built a simple application that applies grid-lines to an image or just simple
I'm trying to do a simple application that will load a local html file

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.