6

The webview doesn't understand what html height 100% means its just showing a blank page. However, in mobile browser it works perfectly fine. Can anyone help me? I've gone through a lot of suggestions but none of that worked. As you can see in the code, I've purposely set the html background color as red so that i can see if the html document is indeed on my webview. I don't see any red at all its just pure white.

It only works if i hard set the height and i don't want to do that. My code is below:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1, maximum-scale=1">
<title>WhyQ</title>
<link href="http://fonts.googleapis.com/css?family=Titillium+Web:400,400italic,700" rel="stylesheet" type="text/css">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>    
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<style>
html{
   margin:0;
   padding:0;
   height:100%;
   min-height:100%;
   background-color:red;
   position:relative;
}
body {
   font-family: 'Titillium Web', sans-serif;
   width: 100%;
   min-height: 100%;
   height: 100%;
   margin: 0 auto;
   padding: 0;
   background-color:red; /*#E9E9E9;*/
   position:relative;
}
</style>
</head>
<body style="position:relative">
<div style="overflow-y:hidden" class="container-fluid login-container">
    <div class="row" style="height:15%;">
        <div class="col-xs-12 txt-center full-height"></div>
    </div>

    <div class="row" style="height:13%;">
        <div class="col-xs-12 txt-center login-sub-container-whyqLogo full-height"></div>
    </div>

    <div class="row" style="height:5%;">
        <div class="col-xs-12 txt-center"></div>
    </div>

    <div class="row" style="height:30%;">
        <div class="col-xs-12 txt-center login-sub-container-whyqMascot full-height"></div>
    </div>

    <div class="row" style="height:20%;">
        <div class="col-xs-12 txt-center full-height"></div>
    </div>

    <div class="row" style="height:16%;">
        <div class="col-xs-12 txt-center full-height">
            <button type="button" class="btn btn-login btn-md" data-toggle="modal" data-target="#loginModal">LOG IN</button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="./new-order.php" class="btn btn-login btn-md" role="button" style="color:white">TRY IT</a>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-dialog-loginForm">
        <div class="modal-content modal-content-loginForm">
            <div class="modal-body modal-body-loginForm">
                <div class="container-fluid">
                    <div class="row-fluid" style="display:none" id="loginName">
                        <input class="login-input" id="txt_name" name="txt_name" type="text" required placeholder=" NAME"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <input class="login-input" id="txt_username" name="txt_username" type="text" required placeholder=" EMAIL"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <input class="login-input" id="txt_password" name="txt_password" type="password" required placeholder=" PASSWORD"><br/><br/>
                    </div>
                    <div class="row-fluid" style="display:none" id="loginPwd2">
                        <input class="login-input" id="txt_password2" name="txt_password2" type="password" required placeholder=" CONFIRM PASSWORD"><br/><br/>
                    </div>
                    <div class="row-fluid" style="display:none" id="loginPhone">
                        <input class="login-input" id="txt_phone" name="txt_phone" type="text" required placeholder=" PHONE NUMBER"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <a href="#"><img class="icon border-radius-3" src="images/g-icon.png" alt="Google" /></a>&nbsp;&nbsp;
                        <a href="#"><img class="icon border-radius-3" src="images/f-icon.png" alt="Facebook" /></a>
                        <button type="button" id="btnRegister" onclick="showRegisterField()" class="btn btn-login-modal btn-sm border-radius-3">SIGN UP</button>&nbsp;&nbsp;
                        <button type="button" onclick="login()" style="margin-right:10px" class="btn btn-login-modal btn-sm border-radius-3">LOGIN</button>
                        <!--<button type="button" class="btn btn-login-modal btn-sm border-radius-3"></button>//-->
                    </div>
                </div>
            </div>
        </div>
      </div>
    </div>

</div>

user3300845
  • 127
  • 2
  • 11

3 Answers3

9

Make sure your webview layout is configured properly:

android:layout_height="match_parent"

If you used wrap_content, the webview itself will shrink to zero so that only blank page is shown.

Terry Lam
  • 1,025
  • 1
  • 12
  • 13
0

Showing red in IE and chrome, I could recommend instead of height: 100%; use height:100vh; as this will set the div to 100% of the view port height. a div tag will not automatically take the height of the view port, you must tell it to do so. also removed the following code as position:relative; is for Tgas not the . also removed the height styles from the row tags. you can set that in css but the height should set itself for each row.

html{
   margin:0;
   padding:0;
    
}
body {
   font-family: 'Titillium Web', sans-serif;
   width: 100%;
   background-color:red; /*#E9E9E9;*/
   
}
.cont-height {
height: 100vh;
}
<div  class="container-fluid login-container cont-height">
    <div class="row" >
        <div class="col-xs-12 txt-center full-height"></div>
    </div>

    <div class="row" >
        <div class="col-xs-12 txt-center login-sub-container-whyqLogo full-height"></div>
    </div>

    <div class="row" >
        <div class="col-xs-12 txt-center"></div>
    </div>

    <div class="row" >
        <div class="col-xs-12 txt-center login-sub-container-whyqMascot full-height"></div>
    </div>

    <div class="row">
        <div class="col-xs-12 txt-center full-height"></div>
    </div>

    <div class="row" >
        <div class="col-xs-12 txt-center full-height">
            <button type="button" class="btn btn-login btn-md" data-toggle="modal" data-target="#loginModal">LOG IN</button>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="./new-order.php" class="btn btn-login btn-md" role="button" style="color:white">TRY IT</a>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-dialog-loginForm">
        <div class="modal-content modal-content-loginForm">
            <div class="modal-body modal-body-loginForm">
                <div class="container-fluid">
                    <div class="row-fluid" style="display:none" id="loginName">
                        <input class="login-input" id="txt_name" name="txt_name" type="text" required placeholder=" NAME"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <input class="login-input" id="txt_username" name="txt_username" type="text" required placeholder=" EMAIL"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <input class="login-input" id="txt_password" name="txt_password" type="password" required placeholder=" PASSWORD"><br/><br/>
                    </div>
                    <div class="row-fluid" style="display:none" id="loginPwd2">
                        <input class="login-input" id="txt_password2" name="txt_password2" type="password" required placeholder=" CONFIRM PASSWORD"><br/><br/>
                    </div>
                    <div class="row-fluid" style="display:none" id="loginPhone">
                        <input class="login-input" id="txt_phone" name="txt_phone" type="text" required placeholder=" PHONE NUMBER"><br/><br/>
                    </div>
                    <div class="row-fluid">
                        <a href="#"><img class="icon border-radius-3" src="images/g-icon.png" alt="Google" /></a>&nbsp;&nbsp;
                        <a href="#"><img class="icon border-radius-3" src="images/f-icon.png" alt="Facebook" /></a>
                        <button type="button" id="btnRegister" onclick="showRegisterField()" class="btn btn-login-modal btn-sm border-radius-3">SIGN UP</button>&nbsp;&nbsp;
                        <button type="button" onclick="login()" style="margin-right:10px" class="btn btn-login-modal btn-sm border-radius-3">LOGIN</button>
                        <!--<button type="button" class="btn btn-login-modal btn-sm border-radius-3"></button>//-->
                    </div>
                </div>
            </div>
        </div>
      </div>
    </div>

</div>
pool pro
  • 2,084
  • 12
  • 21
  • 1
    Hi thanks for your reply but as I've pointed out, the problem is not on the browser but on the webview. I've no problem with the browsers. But I'll try using vh though. – user3300845 Sep 23 '15 at 09:38
0

I had the same problem here:

Android WebView: how to let the css use the entire height w/ position absolute?

I answered my own question, problem was using alignParent instead of match_parent.

I hope that's the problem in your case.

In any case, try to put some borders to your WebView just to see where it actually stops.

FlorianB
  • 2,188
  • 18
  • 30