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>