【发布时间】:2018-01-09 10:39:20
【问题描述】:
在我的应用程序中,我尝试将splash theme 设置为drawable background。如果我使用小图像,它可以正常工作,但是当图像大于屏幕尺寸时,它就不再工作了。
我尝试了所有比例类型和重力,我还能做什么?
这是我的主题:
<style name="SplashTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
这是我的 background_splash.xml
<item android:drawable="@android:color/white" />
<item
android:left="50dp"
android:right="50dp"
>
<bitmap android:src="@drawable/logo_splash"
android:gravity="center|clip_horizontal"
android:scaleType="centerInside"
/>
</item>
这是我的清单(相关代码):
<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>
有什么想法吗?
【问题讨论】:
-
你为什么不直接使用
ImageView和正确的ScaleType而不是设置背景。 -
@ADM 感谢您的回复。这是因为如果您设置了启动布局而不是启动主题,当应用程序启动时会显示片刻白屏,然后您将看到布局。通过这种方式,您立即看到没有白屏的资源
-
@drawable/logo_splash的像素大小是多少? -
@ThomasMary 相当大:1050 x 1050。我稍后会减小它,但无论如何我都希望有一种方法来做到这一点
-
如果在 background_splash.xml 中删除
android:gravity="center|clip_horizontal"会怎样?
标签: android xml splash-screen scaletype