Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap vertical scroll

Tags:

cordova

I am building a phonegap app for ios and have vertical scroll issue. There appears to be a few pixels scroll in the webview even without any content and this is affecting my absolutely positioned nav bar and tab bar built in html

Here is the html page I have - there is no content by I still get the scroll amount shown in the image:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <title>My App</title>
    </head>
    <body>

        <script src="scripts/vendor/cordova-2.4.0.js"></script>
    </body>
</html>

scroll screenshot http://img20.imageshack.us/img20/5140/screenshot20130225at212.png

like image 741
jamie holliday Avatar asked Nov 29 '22 13:11

jamie holliday


2 Answers

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

<meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, width=device-width" />

And in config.xml:

<preference name="DisallowOverscroll" value="true" />

Above are settings I found to be the best start for handling scroll on iOS. Then, just add 'overflow: auto' to any element you need to scroll. Use overthrow or iscroll to help support iOS < 5, android < 3, and and so on.

like image 160
Noogen Avatar answered Dec 02 '22 03:12

Noogen


This solved it for me (on iOS at least - may have other compatibility things on other platforms)

Try removing width=device-width, height=device-height from your meta at the top.

It's an issue with the device not factoring for the status bar at the top as far as I can tell.

like image 45
jocull Avatar answered Dec 02 '22 02:12

jocull