Android 可作为splash主题的背景绘制';t保持率

Android 可作为splash主题的背景绘制';t保持率,android,xml,splash-screen,scaletype,Android,Xml,Splash Screen,Scaletype,在我的应用程序中,我试图将splash t血红素设置为可绘制背景。如果我使用小图像,它可以正常工作,但是当图像大于屏幕大小时,它就不再工作了 图像水平缩放正确,但高度不正确,如下所示: 我尝试了所有的鳞片和重力,我还能做什么 这是我的主题: <style name="SplashTheme" parent="AppTheme"> <item name="android:windowBackground">@drawable/background_splash&l

在我的应用程序中,我试图将
splash t
血红素设置为
可绘制背景。如果我使用小图像,它可以正常工作,但是当图像大于屏幕大小时,它就不再工作了

图像水平缩放正确,但高度不正确,如下所示:

我尝试了所有的鳞片和重力,我还能做什么

这是我的主题:

<style name="SplashTheme" parent="AppTheme">
    <item name="android:windowBackground">@drawable/background_splash</item>
</style>
    <activity
        android:name=".activities.SplashScreenActivity"
        android:configChanges="orientation|screenSize"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

@可绘制/背景\u飞溅
这是我的背景\u splash.xml


这是我的清单(相关代码):

<style name="SplashTheme" parent="AppTheme">
    <item name="android:windowBackground">@drawable/background_splash</item>
</style>
    <activity
        android:name=".activities.SplashScreenActivity"
        android:configChanges="orientation|screenSize"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


有什么想法吗?

你可以在你的背景中使用这样的图层列表。\u splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@android:color/white"
        android:gravity="fill" />

    <item
        android:drawable="@drawable/logo_splash"
        android:gravity="center" />
</layer-list>

这将使您的图像在屏幕上居中,左侧空间将由白色背景色填充

可能您必须添加不同大小的图像,如您可以在此处阅读的:

如果这样做,则可以使用相同的名称访问图像。您的项目结构如下所示:

如果要删除启动屏幕中的操作和状态栏,可以在启动主题中添加以下行:

<item name="android:windowFullscreen">true</item>
true

为什么不使用带有适当的
缩放类型的
ImageView
而不是设置背景呢。@谢谢您的回复。这是因为如果你设置了一个启动布局而不是一个启动主题,当应用程序启动时会显示一个白色屏幕,然后你就会看到布局。通过这种方式,您可以立即看到没有白色屏幕的资源您的
@drawable/logo\u splash
的像素大小是多少?@ThomasMary相当大:1050 x 1050。稍后我会减少它,但我希望有一种方法可以做到这一点,如果您删除background_splash.xml中的
android:gravity=“center | clip_horizontal”