实现Walker之闪屏界面的实现分析

来源:互联网 发布:神经网络算法 反馈 编辑:程序博客网 时间:2024/06/13 03:37

界面效果


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{@Overrideprotected 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(){@Overridepublic void onAnimationEnd(Animation animation) {// TODO Auto-generated method stubIntent intent=new Intent(WelcomeActivity.this,LoginActivity.class);startActivity(intent);}@Overridepublic void onAnimationRepeat(Animation aimation) {// TODO Auto-generated method stub}@Overridepublic void onAnimationStart(Animation animation) {// TODO Auto-generated method stub}});  }

  方式2:使用Handler完成跳转:

               /*//2、使用Handler完成跳转new Handler().postDelayed(new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubIntent 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();}





0 0
原创粉丝点击