3

I am using a WebView in Android to load some local html that scales an image to the screen as a background... however, when I go to start the activity that loads the WebView I get a very brief flash of white screen before the image loads. It is not a huge deal, but I would like to avoid this... I have tried setting the background of all the related elements to black, but it still happens... any ideas?

Here's my html:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">

    <title>NerdRAGE</title>

    <style>
        * { margin: 0; padding: 0; }

        html { 
            background: url(images/10_1.jpg) no-repeat center center fixed; 
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
        }


    </style>
</head>

<body bgcolor="#000000">



</body>

</html>

Here's my XML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#000000" android:layout_width="fill_parent" android:layout_height="fill_parent">
<WebView  
    android:id="@+id/mapview"
    android:background="#000000" android:scaleType="centerInside" android:layout_gravity="center_vertical|center_horizontal" android:clickable="false" android:fitsSystemWindows="true" android:scrollbars="none" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
    </LinearLayout>
Frank Bozzo
  • 15,033
  • 6
  • 25
  • 29

1 Answers1

0

Found this post on here:
How to prevent the white 'flash' on page load created by background image loading delay?

Try setting a background colour to the html element and remove the bgcolor="#000" inline style on the body element (this should be avoided. it's bad practise).

html {background: #[color] url('images/10_1.jpg') no-repeat center center fixed; }
Community
  • 1
  • 1
Tom Gillard
  • 575
  • 5
  • 21
  • Not worked even I set #000 before url(). It is still white screen before image is loaded. Setting WebView background to transparent also no luck because the DOM tree DO loaded. Just the background no yet loaded and it is white. – Yeung Aug 15 '14 at 10:17