android studio:创建android启动画面

时间:2018-06-18 07:17:45

标签: java android

您好我正在尝试为Android创建一个启动画面,我想要的背景就是这个。 Splash background

我想通过设置android的样式和主题来实现这一点,而不是使用线程来运行启动画面,因为我听说这样做更好。

所以这是我的布局:

styles.xml

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>


<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">

    <item
        name="android:windowBackground">@drawable/splash</item>
</style>

android Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.recouture">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".SplashScreenActivity"
        android:theme="@style/SplashTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".MainActivity"></activity>
</application>

SplashScrenActivity.java

public class SplashScreenActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        startActivity(new Intent(SplashScreenActivity.this,MainActivity.class));

        finish();
    }
}

问题在于我的drawable中的splash.xml布局。我不知道如何在我的splash.xml中设置多个图像,因为在线教程只教您如何使用单个徽标设置启动画面。

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

我将这些徽标导入我的android studio:

logo1

logo2

logo3

感谢任何帮助!

0 个答案:

没有答案
相关问题