Android 欢迎页快速启动
大家应该都知道,在默认情况下,Android App在点击App logo到App完全启动这之间会有一段时间空白期。那么如何做到在用户点击logo图标之后立即打开App的界面而不是一段白屏或黑屏呢?
设置xml
在drawable下建立welcome.xml
android:gravity="center"
android:src="@mipmap/welcome_page"/>
设置style
@drawable/welcome
清单文件中配置style
android:name=".ui.WelcomeActivity"
android:windowSoftInputMode="adjustNothing" android:theme="@style/WelcomeThem">
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就足够了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。