Android实现闪屏效果

  

在登陆一些页面时,通常能看见“一闪而过”效果并进入页面。下面看看是怎样实现这样的效果的吧

  

首先,在布局里(可以说和平常没有什么不同),划线部分是进度条:

        & lt; RelativeLayout xmlns: android=" http://schemas.android.com/apk/res/android "   xmlns:工具=" http://schemas.android.com/tools "   android: layout_width=" match_parent "   android: layout_height=" match_parent "   android:背景=癅drawable/bg”比;      & lt; ImageView   android: id=癅 + id/欢迎”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_centerHorizontal=" true "   android: layout_marginBottom=" 45 dp "   android: src=" https://www.yisu.com/zixun/@drawable欢迎”/比;      & lt; ProgressBar   android: id=癅 + id/progressBar”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_below=癅 + id/欢迎”   android: layout_centerHorizontal=" true "   android: layout_marginBottom=" 70 dp”/比;      & lt; TextView   android: id=癅 + id/textView1”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_below=癅 + id/progressBar”   android: layout_centerHorizontal=" true "   android:填充=" @dimen/padding_medium”   android:文本=" @string/欢迎”   android: textAppearance=" & # 63; android: attr/textAppearanceMedium”   工具:上下文="。MainActivity”/比;      & lt;/RelativeLayout>      

在字符串中定义:

        & lt; resources>      & lt;字符串名称=" app_name "祝辞ShanP01   & lt;字符串名称=盎队弊4腔队尤? \ n一起快乐学习! & lt;/string>//(\ n)实现换行   & lt;字符串名称=" menu_settings "祝辞Settings   & lt;字符串名称=" title_activity_main "祝辞MainActivity   & lt;字符串名称=" title_study "祝辞学习& lt;/string>   & lt;字符串名称=" title_search "祝辞搜查& lt;/string>   & lt;字符串名称=" title_game "祝辞游戏& lt;/string>   & lt;字符串名称=" title_save "祝辞保存& lt;/string>   & lt;字符串名称=皌itle_help”在帮助& lt;/string>   & lt;字符串名称=" title_activity_welcome "祝辞WelcomeActivity      & lt;/resources>      

如果想在运行项目时不显示标题栏,则在想隐藏标题栏的活动中加一句即可(在AndroidManifest.xml文件中):

        android:主题=" @android:风格/主题。NoTitleBar "      

最主要的实现方法:

  

        公开课WelcomeActivity延伸活动{   私人ImageView welcomeImage;   @Override   公共空间>   公共空间onCreate(包savedInstanceState) {   super.onCreate (savedInstanceState);   setContentView (R.layout.activity_welcome);   welcomeImage=(ImageView) this.findViewById (R.id.welcome);   AlphaAnimation AlphaAnimation=new AlphaAnimation(0.1, 1.0);////定义1个具有淡入效果的对象   welcomeImage.startAnimation (alphaAnimation);   新处理程序()。postDelayed(新Runnable () {   @Override   公共空间run () {   目的意图=new意图();   intent.setClass (WelcomeActivity。这一点,MainActivity.class);   startActivity(意图);   完成();   }   },3000);//细心不要漏了   }   之前      

你觉得哪一种更适合你呢?

  

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

Android实现闪屏效果