Android编程入门--简单闪屏界面

仰天大笑出门去,我辈岂是蓬蒿人。这篇文章主要讲述Android编程入门--简单闪屏界面相关的知识,希望能为你提供帮助。
Manifest

< activity android:name=".ui.activity.WelcomeActivity" android:theme="@style/SplashTheme"> < intent-filter> < action android:name="android.intent.action.MAIN" /> < category android:name="android.intent.category.LAUNCHER" /> < /intent-filter> < /activity>

【Android编程入门--简单闪屏界面】style
< style name="SplashTheme" parent="Theme.AppCompat.NoActionBar"> < !-- 闪屏背景,可用图片 --> < item name="android:windowBackground"> @drawable/layer_splash< /item> < item name="android:windowFullscreen"> true< /item> < item name="android:windowNoTitle"> true< /item> < /style>

layer
< ?xml version="1.0" encoding="utf-8"?> < layer-list xmlns:android="http://schemas.android.com/apk/res/android"> < !-- 背景颜色 --> < item android:drawable="@color/white" /> < item> < !-- 图片 --> < bitmap android:gravity="center" android:src="https://www.songbingjia.com/android/@mipmap/logo" /> < /item> < /layer-list>

activity
package com.zyp.energy.ui.activity; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.support.v7.app.AppCompatActivity; import com.zyp.energy.R; public class WelcomeActivity extends AppCompatActivity {@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new Handler().postDelayed(new Runnable() {@Override public void run() { Intent intent = new Intent(WelcomeActivity.this, MainActivity.class); startActivity(intent); finish(); } }, 500); }@Override public void finish() { super.finish(); overridePendingTransition(R.anim.fade, R.anim.hold); } }

 

    推荐阅读