1

I'm using cordova webview to wrap my live online webapp.

And I need to set a background for the cordova webview.

Apparently, specifying android:background attribute won't work on cordova webview. So I'm looking for a way to set a background for cordova webview.

Packaging in either pictures or webpage are OK for me.

Here is a related question I just asked. And as suggested in the answer, I can use the cache to load the webpage in advance. However it is done in runtime. What I need now is to burn the background, or cache into the app.

Community
  • 1
  • 1
SolessChong
  • 3,370
  • 8
  • 40
  • 67
  • Can you provide some code? Cordova apps are just HTML5 applications, you should just be able to use CSS to specify a background image on the `body` of your HTML and it should work. – MBillau May 30 '13 at 12:54
  • Yes phonegap is based on HTML. However I'm looking for ways of setting background before loading HTML, because all my html are on-line. The code in my app is no more than CordovaWebView.loadUrl("http://www.google.com"); @MBillau – SolessChong May 30 '13 at 13:05

1 Answers1

1

Try using a Cordova splash screen. The API is here: http://docs.phonegap.com/en/edge/cordova_splashscreen_splashscreen.md.html#Splashscreen

public class splashScreen extends DroidGap
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        //super.loadUrl("file:///android_asset/www/index.html");
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        super.loadUrl("http://www.google.com",10000);
    }
}

Make sure that you create a splash.png image and save it in your /res/drawable/ folder.

This should have the effect of displaying a "background" on the WebView while your external URL loads, instead of just showing a black screen.

MBillau
  • 5,366
  • 2
  • 28
  • 29