相关疑难解决方法(0)

Android 独特的闪屏:如何让它填满屏幕?

我有一个独特的启动画面,名为 splash.png,大小为 1280x1280, 150dpi,我react-native-bootsplash在 React Native 项目中使用,但我认为这并不重要。

我的问题很简单:如何使我的启动画面在纵向模式下成为全高,而不是更少,而不是更多,并保持其纵横比,以便图片填满屏幕。就像background-size: cover在 css 中一样。或者像一个简单的<Image resizeMode="cover" style={{ height: '100%' }} />React Native 中。

所以我有 :

android/app/src/main/res/values/styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textColor">#000000</item>
    </style>

    <!-- BootTheme should inherit from AppTheme -->
    <style name="BootTheme" parent="AppTheme">
        <!-- set the generated bootsplash.xml drawable as activity background -->
        <item name="android:windowBackground">@drawable/bootsplash</item>
        <item name="android:windowNoTitle">true</item>
    </style>

</resources>
Run Code Online (Sandbox Code Playgroud)

android/app/src/main/res/drawable/bootsplash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" …
Run Code Online (Sandbox Code Playgroud)

xml android splash-screen react-native react-native-android

12
推荐指数
1
解决办法
5892
查看次数