0

白色のステータス バーとナビゲーション バーを備えたアプリケーションがあります。このようなスプラッシュテーマを定義しました。

<style name="Theme.MySplash" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">#00f</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/ic_baseline_play_arrow_24</item>
    <item name="windowSplashScreenAnimationDuration">200</item>

    <item name="postSplashScreenTheme">@style/Theme.AppTheme</item>
</style>

<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:statusBarColor">#fff</item>
    <item name="android:navigationBarColor">#fff</item>
</style>

主な活動

class MainActivity : AppCompatActivity() {

    var keepSplashScreen = true

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val splashScreen = installSplashScreen()

        splashScreen.setOnExitAnimationListener { splashScreenProvider ->
            val fadeAnim = ObjectAnimator.ofFloat(
                splashScreenProvider.view, View.ALPHA, 1f, 0f
            )
            fadeAnim.duration = 4000L
            fadeAnim.interpolator = AccelerateInterpolator()
            fadeAnim.doOnEnd { splashScreenProvider.remove() }
            fadeAnim.start()
        }
        splashScreen.setKeepVisibleCondition { keepSplashScreen }
        setContentView(R.layout.activity_main)

        Handler(Looper.getMainLooper()).postDelayed({
            keepSplashScreen = false
        }, 3000)
    }
}

SplashThemeデバイス Android 12 (Pixel 4XL) では問題なく動作しますが、Android 8 (Xiomi A2) ではSplashThemeフルスクリーン表示されません。

ここに画像の説明を入力

このビデオから、SplashScreenexist を開始すると (フェード アニメーション)、白いステータス バーとナビゲーション バーが表示されます (Android 12 では、SplashScreenexist 中は常にフルスクリーン)。SplashScreenAndroid < 12で常にフルスクリーンにするにはどうすればよいですか?

4

2 に答える 2

1

コンパクトライブラリを使用していない可能性があると思います。サポート ライブラリを使用していない場合、スプラッシュ スクリーンは以前とまったく同じ古い外観になります。

implementation 'androidx.core:core-splashscreen:1.0.0-alpha01'

SplashScreen は、実際には画像ビューを含むフレーム レイアウトを使用します。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false">

  <ImageView
      android:id="@+id/splashscreen_icon_view"
      android:layout_width="?attr/splashScreenIconSize"
      android:layout_height="?attr/splashScreenIconSize"
      android:layout_gravity="center"/>

</FrameLayout>
于 2021-12-14T09:19:27.030 に答える
0

これを試して:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 

onCreateメソッド内に記述します。詳細については、こちらをお読みください

于 2021-12-14T08:47:00.943 に答える