源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android实现欢迎页快速启动的方法

  • 时间:2020-06-01 22:27 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android实现欢迎页快速启动的方法
[b]Android 欢迎页快速启动[/b] 大家应该都知道,在默认情况下,Android App在点击App logo到App完全启动这之间会有一段时间空白期。那么如何做到在用户点击logo图标之后立即打开App的界面而不是一段白屏或黑屏呢? [b]设置xml [/b] 在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>
[b]设置style[/b]
<!-- 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>
[b]清单文件中配置style[/b]
<!-- 欢迎页 -->
  <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>
[b]Activity中不需要设置setContentView()[/b]
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就足够了。 [b]总结[/b] 以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对编程素材网的支持。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部