I'm developing a Windows Phone app using PhoneGap/Cordova (though, I believe the problem I'm having makes the fact that it's PhoneGap irrelevant). No matter what I seem to do, the tag of my html pages doesn't fill the screen vertically. It looks fine when running the pages in Chrome or even IE Here is what it looks like on the Emulator, I added a blue border to the tag in the .css for emphasis of what's going on:
Here's the css for the body:
body{
border: 1px blue solid;
}
html, body{
height:100%;
min-height:100%
}
here's the footers css:
div.navbar_table_container {
width: 100%;
height: auto;
position: absolute;
bottom: 0;
background-image:url(images/bottom-nav.png);
background-size:100% 100%;
background-repeat:no-repeat;
text-align: center;
}
and, as it may be important, here's the xaml file:
<phone:PhoneApplicationPage
x:Class="CordovaWP8_2_7_01.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Background="White"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" d:DesignHeight="820" d:DesignWidth="480"
xmlns:my="clr-namespace:WPCordovaClassLib">
<Grid x:Name="LayoutRoot" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<my:CordovaView HorizontalAlignment="Stretch"
Margin="0,0,0,0"
x:Name="CordovaView"
VerticalAlignment="Stretch" />
<Image Source="SplashScreenImage.jpg"
x:Name="SplashImage"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Image.Projection>
<PlaneProjection x:Name="SplashProjector" CenterOfRotationX="0"/>
</Image.Projection>
</Image>
</Grid>
</phone:PhoneApplicationPage>
an important note is that it works the way I want it to in Chrome, IE, and when I run it as an android app.
The closest question to mine that I could find was Phonegap Windows Phone gap space bottom but the answer there doesn't help me.
I've noticed recently that when I run the same code off of a web server and access it using IE on a windows phone, it looks fine. However, I did notice that whenever an Alert was shows on the phone, the address bar of IE goes away and leaves behind the EXACT same gap from the bottom of the web content to the bottom of the phone as the native app is always showing.
So, that leads me to believe that, even though it's an "app", if it's running html and javascript, the phone leaves space for an address bar, even though it's never used.
Any help or insight would be greatly appreciated.
I tried using device-height in the viewport meta tag, however I learned that IE doesn't support that tag. Then after my 100,000 google search, I found this page.
After adding this to my CSS:
@viewport{height:device-height}
@viewport{width:device-width}
@-ms-viewport{height:device-height}
@-ms-viewport{width:device-width}
and adding this to a JavaScript file that hits all of my pages:
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
);
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{height:device-height!important}"
)
);
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
Then my 100% body height started acting the way that I would expect it to.
In your MainPage.xaml
file, change
shell:SystemTray.IsVisible="True"
to
shell:SystemTray.IsVisible="False"
it seems that the key is width property in -ms-viewport, so a simpler solution would be:
// put this in body or after body as it uses document.body.offsetWidth.
if (/IEMobile\/10\.0/.test(navigator.userAgent)) {
document.write('<style>@-ms-viewport { width: ' + document.body.offsetWidth + 'px; }</style>');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With