我是靠谱客的博主 忧虑音响,这篇文章主要介绍Android App启动图启动界面(Splash)的简单实现代码,现在分享给大家,希望可以做个参考。

第一步:创建一个Activity

第二步:创建一个新的Activity 命名为Splash

new -> Activity -> Empty Activity

p>第三步:将准备好的启动图片放到drawable目录下,并修改Splash的xml布局文件,如下图所示

第四步:修改SplashActivity中的代码如下

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.WindowManager; public class Splash extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate( savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隐藏状态栏 getSupportActionBar().hide();//隐藏标题栏 setContentView(R.layout.activity_splash); Thread myThread=new Thread(){//创建子线程 @Override public void run() { try{ sleep(5000);//使程序休眠五秒 Intent it=new Intent(getApplicationContext(),MainActivity.class);//启动MainActivity startActivity(it); finish();//关闭当前活动 }catch (Exception e){ e.printStackTrace(); } } }; myThread.start();//启动线程 } }

注 意

复制代码
1
2
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getSupportActionBar().hide();

需要在 setContentView(R.layout.activity_splash);

之前执行

第五步:修改配置文件AndroidManifest中的代码


将上述代码的intent filter标签移动到name为.Splash的Activity标签下(将启动页面修改为SplashActivity),如下图

好了,现在大功告成了,快运行代码试试效果怎么样

总结

到此这篇关于Android App启动图启动界面(Splash)的简单实现的文章就介绍到这了,更多相关Android App启动图启动界面(Splash)的简单实现内容请搜索靠谱客以前的文章或继续浏览下面的相关文章希望大家以后多多支持靠谱客!

最后

以上就是忧虑音响最近收集整理的关于Android App启动图启动界面(Splash)的简单实现代码的全部内容,更多相关Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(247)

评论列表共有 0 条评论

立即
投稿
返回
顶部