本文主要是介绍在一个界面条跳转到下一个界面之间现动画跳转,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
java文件:
package com.example.com.text;
import android.app.Activity;import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;
public class WelcomeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_welcome);
//this.setContentView(R.layout.letao_myletao_code_shoes);
Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 2:
Intent intent = new Intent(WelcomeActivity.this , MainActivity.class);
//overridePendingTransition(R.anim.zoomin,R.anim.zoomout);//在跳转的语句后加上这条语句
WelcomeActivity.this.startActivityForResult(intent, 0);
WelcomeActivity.this.finish();
int version = Integer.valueOf(android.os.Build.VERSION.SDK);
if(version > 5 ){
overridePendingTransition(R.anim.zoomin, R.anim.zoomout);
}
WelcomeActivity.this.finish();
default:
break;
}
super.handleMessage(msg);
}
};
handler.sendEmptyMessageDelayed(2, 900L);
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}
zoom.xml文件
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator">
<scale android:fromXScale="0.1" android:toXScale="1.0"
android:fromYScale="0.1" android:toYScale="1.0"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="3000" />
<!-- 这里为了看到动画演示效果,把动画持续时间设为3秒 -->
<alpha
android:fromAlpha="0.1"
android:toAlpha="1.0"
android:duration="1000" />
</set>
zoomout.xml文件
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top">
<scale android:fromXScale="1.0" android:toXScale=".5"
android:fromYScale="1.0" android:toYScale=".5"
android:pivotX="50%p" android:pivotY="50%p"
android:duration="3000" />
<!-- 系统内置的动画持续时间
android:duration="@android:integer/config_mediumAnimTime"
-->
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="1000"/>
</set>
这篇关于在一个界面条跳转到下一个界面之间现动画跳转的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!