Question

I have been building an android app in this period and it has 3 WebView components because I really need them. Is also known that apps built with Delphi take some seconds before starting and so does mine.

I was trying to put a splash image that appears while the app is loading. Then, when everything is ready, the splash disappears and the program starts.

Do you have any idea? I was looking for some OnCreate event but I don't think it's what I really need. Also, I haven't found a lot of documentation online. Any help would be appreciated..

Was it helpful?

Solution

First, sorry my bad english.

  1. You must create new folder on root and rename it "res".

  2. What you want see loading image? Copy it in "res" folder.

  3. You must create styles.xml in "res" folder.

    This is styles.xml:

    <? Xml version="1.0" encoding="UTF-8"?>
    <resources>
    <Style name = "MyTheme . notitleb is . custombackground "parent =" @ android: Theme . Black ">
        <item name="android:windowbackground"> ​​@ drawable / loading </ item>
        <item name="android:windownotitle"> true </ item>
        <item name="android:windowfullscreen"> true </ item>
        <item name="android:windowcontentoverlay"> @ null </ item>
    </ Style>
    </ Resources>
    
  4. Open project and open top menu in Project>>Deployment, well opening deployment screen.

  5. Click add button and add res\loading.png, res\styles.xml

  6. But this 2 folders platforms only Android fix it.

  7. Look at Remote Path columns and change this:

    • Loading.png = res\drawable-port
    • styles.xml = res\values
  8. After making the adjustments, press CTRL + F9 one time and "androidmanifest.template.xml" file will give rise to.

  9. Open "AndroidManifest.template.xml"

  10. Change this : android:theme=”%theme%”

    Like This : android:theme=”@style/MyTheme.NoTitleBar.CustomBackground

  11. After you save the file by pressing F9 can enjoy.

ORIGINAL TOPIC = http://brsatalay.com/?p=336

OTHER TIPS

In res/values/styles.xml (create it if you don't have it), you need to declare a theme for your application like this:

<style name="MyTheme" parent="android:Theme.Holo.Light">
        <item name="android:windowBackground">@drawable/splash_image</item>
</style>

And then, in AndroidManifest.xml file, under the application tag, you need to add this:

android:theme="@style/MyTheme"

And that is all. OnCreate is only called after the loading is done!

private class LoginWebClient extends WebViewClient {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }
}

Splash screens for android is a bad design. See http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ for example. Show progress bar instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top