Insert a Splashscreen or imageView into crosswalk webview app

-1

I have an application on crossview webview. as my site takes about 5 seconds to open on the screen, I thought of inserting a splashscreen or imageview (I do not know if it has any difference between the two - I'm still starting) and leave it appearing for 5 seconds on the screen.

I also saw people inserting the splash screen or imageview on the home screen and it disappears when the page is loaded.

Both solutions would be great, but I can not do that.

Below I'll leave my code.

MaindActivity.java

package com.ovortex.myapplication;

import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import org.xwalk.core.XWalkActivity;
import org.xwalk.core.XWalkView;

public class MainActivity extends XWalkActivity {



    private XWalkView xWalkWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        xWalkWebView=(XWalkView)findViewById(R.id.xwalkWebView);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//<----verifica se o dipositivo é api 19 / Android 4.4

            getWindow().getDecorView().setSystemUiVisibility(

                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                            | View.SYSTEM_UI_FLAG_LOW_PROFILE
                            | View.SYSTEM_UI_FLAG_FULLSCREEN // esconde a barra de status
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }

    }

    @Override
    protected void onXWalkReady() {
        // carregar uma url local
        xWalkWebView.loadUrl("http://xxxxxx.com");
    }


}

activity.main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ovortex.myapplication.MainActivity">

    <org.xwalk.core.XWalkView
        android:id="@+id/xwalkWebView"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#fff"
        />

</RelativeLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ovortex.myapplication">

    <uses-permission android:name="android.permission.INTERNET"/>



    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
    
asked by anonymous 15.07.2017 / 00:03

1 answer

0

First of all, you should only have MainActivity. The layout of it will look like this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            >

            <org.xwalk.core.XWalkView
                android:id="@+id/xwalkWebView"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#fff"
                >

            </org.xwalk.core.XWalkView>

        </android.support.v4.widget.SwipeRefreshLayout>

    </RelativeLayout>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:id="@+id/splash">

        <!--Aqui vai qualquer elemento da sua splash, ou tema -->

    </LinearLayout>
</FrameLayout>

Then in your MainActivity, what you will do: Once you load the site, you will hide the splash view, more specifically in this piece (correct me if I am wrong, I have never used XWalk blzz)

mWebview.setResourceClient(new XWalkResourceClient(mWebview){
        public void onProgressChanged(XWalkView view, int progress) {
            if (progress == 100) {
                findViewById(R.id.splash).setVisibility(View.GONE);
            }
        }
    });

Test and give me feedback.

    
21.07.2017 / 21:14