实现Walker之闪屏界面的实现分析
2016-05-29 13:14
246 查看
界面效果
1.修改自动生成的activity_welcom.xml文件,代码如下:
方式1:利用动画持续时间,动画结束后跳转,主要代码:
方式2:使用Handler完成跳转:
1.修改自动生成的activity_welcom.xml文件,代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layoutWelcome" android:layout_width="match_parent" android:layout_height="match_parent" <strong>android:background="@drawable/welcome_bg"</strong> tools:context=".WelcomeActivity"> </RelativeLayout>2.修改AndroidManifest.xml文件,修改闪屏界面为全屏模式:
<activity android:name="cn.edu.bztc.walkersimulate.WelcomeActivity" android:label="@string/title_activity_welcome" <strong>android:theme="@android:style/Theme.NoTitleBar.Fullscreen"</strong> >3.修改WelcomeActivity.java中的代码,实现停顿3秒后跳转
方式1:利用动画持续时间,动画结束后跳转,主要代码:
public class WelcomeActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); /*//1、利用动画持续时间,动画结束后跳转 RelativeLayout layoutWelcome=(RelativeLayout)findViewById(R.id.layoutWelcome); AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f); alphaAnimation.setDuration(3000); layoutWelcome.startAnimation(alphaAnimation); alphaAnimation.setAnimationListener(new AnimationListener(){ @Override public void onAnimationEnd(Animation animation) { // TODO Auto-generated method stub Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class); startActivity(intent); } @Override public void onAnimationRepeat(Animation aimation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } }); }
方式2:使用Handler完成跳转:
/*//2、使用Handler完成跳转 new Handler().postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class); startActivity(intent); } }, 3000);方式3:使用多线程完成跳转:
//3、使用多线程完成跳转 new Thread(){ public void run(){ try{ Thread.sleep(3000); Intent intent = new Intent(WelcomeActivity.this,GuideActivity.class); startActivity(intent); }catch(InterruptedException e){ e.printStackTrace(); } }; }.start(); }
相关文章推荐
- zznu 1257 HDU1052 田忌赛马
- STL学习笔记--4、序列式容器之list
- codeforces 676A A. Nicholas and Permutation(水题)
- 强大的原生DOM选择器querySelector和querySelectorAll
- Hadoop 介绍与环境安装
- JAVA——LineNumberReader
- BZOJ3426: Poi2013 Tower Defense Game
- Duilib扩展—双击、右键消息扩展
- 第二阶段团队冲刺个人工作总结五
- Mac上Safari不能关键字搜索
- iOS-OC中的self.a与_a访问区别简析
- auto和bool
- 获取url
- 今天开始写技术博客,聊技术,聊梦想,共同成长!
- UVa 11346 Probability (转化+积分+概率)
- 第4章第3节 二叉树的基本操作(非递归实现)
- 基础BFS+DFS poj3083
- ubuntu系统 /etc目录下配置文件的作用
- 【编程马拉松】【005-猴子分桃】
- IIPP迷你项目(一)“Rock-paper-scissor-lizard-Spock”