虚位以待(AD)
虚位以待(AD)
首页 > 软件编程 > Android编程 > Android实现欢迎页快速启动的方法

Android实现欢迎页快速启动的方法
类别:Android编程   作者:码皇   来源:互联网   点击:

这篇文章主要给大家介绍了Android实现欢迎页快速启动的方法,文中给出了详细的方法介绍,对大家具有一定的参考价值,需要的朋友们可以一起来学习学习。

Android 欢迎页快速启动

大家应该都知道,在默认情况下,Android App在点击App logo到App完全启动这之间会有一段时间空白期。那么如何做到在用户点击logo图标之后立即打开App的界面而不是一段白屏或黑屏呢?

设置xml

在drawable下建立welcome.xml

    <?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="@mipmap/welcome_page"/> </item></layer-list>

设置style

    <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> </style> <style name="WelcomeThem" parent="AppTheme"> <item name="android:windowBackground">@drawable/welcome</item> </style>

清单文件中配置style

    <!-- 欢迎页 --> <activity android:name=".ui.WelcomeActivity" android:windowSoftInputMode="adjustNothing" android:theme="@style/WelcomeThem"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>

Activity中不需要设置setContentView()

    public class WelcomeActivity extends AppCompatActivity {
    @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    finish();
    }
    }

不需要为你的SplashActivity设置一个视图,这个视图来自于主题,在主题中为你的SplashActivity设置UI就足够了。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。

相关热词搜索: android 快速启动 android 欢迎页面 andro