[英]is there a way to show splash screen until the webview fragment finish loading?
我有一個首先安裝 SplashScreen installSplashScreen()
的 MainActivity,然后它將加載WebView
,webviewFragment 在其他文件中,我正在嘗試使用splashScreen.setKeepOnScreenCondition{ }
來保持啟動畫面顯示,直到 webviewFragment 到達onPageFinished()
state,我該怎么做?
有幾種方法可以傳達這兩個組件:
您可以使用這樣的布局
<?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>
現在加載您的 url,然后在您的onPageFinished()
調用中。
binding.webView.visibility = View.Visible
binding.root.removeView(binding.clContainerSplash)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.