Android:中心闪屏图像

标签 android splash-screen

我有一个带有启动画面的应用程序,启动画面在小型设备上看起来不错,但在大型平板电脑(模拟器)上看起来很糟糕。所以我将背景更改为 wrap_content。但它看起来与屏幕的一侧对齐,有人能告诉我一种使背景图像居中的方法吗?这是我的 splash.xml-

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/splash">
</LinearLayout>

最佳答案

我正在为我的 Activity 使用背景图片。首先在 styles.xml 中创建一个主题:

<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/background_splash</item>
</style>

然后创建一个名为 background_splash.xml 的新绘图

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/colorWhite"/>
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/logo_splash"/>
    </item>
</layer-list>

然后在您的 AndroidManifest.xml 中设置您的 Activity 以使用此主题:

<activity android:name="SplashActivity" android:theme="@style/SplashTheme" >

这对我有用。

关于Android:中心闪屏图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39212977/

相关文章:

android - 集成 Appboy 反馈 fragment

java - Android 4.4 ConsumerIr.transmit 变得疯狂

android - 使用图层列表不包裹父屏幕的背景可绘制

java - 带有进度条的应用程序和启动画面的初始化 (Swing)

android - httpurlconnection 中的问题获取状态 500

android - 我将如何从 android 中的 DialogFragment 启动 TimepickerDialog?

android - 在 Memory kill 或 Destroy Activity 时服务和 BroadcastReceiver 在 MI 手机中不工作

java - 作为 JavaFX 应用程序启动画面的图像不会自动隐藏

WPF 启动画面,直到 Windows 结束加载

android - react native 启动画面 : Unfortunately <APP> has stopped after SplashScreen. show()