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就足够了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。
相关文章
ActivityManagerService广播并行发送与串行发送示例解析
这篇文章主要为大家介绍了ActivityManagerService广播并行发送与串行发送示例解析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-03-03解决webview调用goBack()返回上一页自动刷新闪白的情况
本文主要介绍了解决webview调用goBack()返回上一页自动刷新闪白的情况。具有很好的参考价值。下面跟着小编一起来看下吧2017-03-03Android获取清单文件中的meta-data,解决碰到数值为null的问题
这篇文章主要介绍了Android获取清单文件中的meta-data,解决碰到数值为null的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-03-03
最新评论