Reputation: 29
I have a MainActivity that installSplashScreen()
at first, then it will load the WebView
, the webviewFragment is in other file, I am trying to use splashScreen.setKeepOnScreenCondition{ }
to keep splash screen showing until the webviewFragment reach to onPageFinished()
state, how am I supposed to do that?
Upvotes: 0
Views: 158
Reputation: 3068
You can use a layout 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_container_splash"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
Now load your url, and in your onPageFinished()
call following.
binding.webView.visibility = View.Visible
binding.root.removeView(binding.clContainerSplash)
Upvotes: 0
Reputation: 19273
There are several alternatives to communicate both components:
Upvotes: 1