Activity 切换效果,androidwifi 密码
对应启动时设置?
package com.wust.myanimation;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.BounceInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView tv_hello_world;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void tiaozhuan(View view) {
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
//淡入 淡出 的动画效果
// overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
//从左向右 的滑动效果
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
}
}
对应退出时设置
package com.wust.myanimation;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
/**
ClassName: SecondActivity <br/>
Description: <br/>
date: 2021/7/18 12:43<br/>
@author yiqi<br />
@QQ 1820762465
@微信 yiqiideallife
@技术交流 QQ 群 928023749
*/
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
@Override
public void finish() {
super.finish();
//淡入 淡出 的动画效果
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
//从左向右 的滑动效果
// overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
}
}
效果展示
?利用自定义动画设置
第一步:在 res/anim/ 文件夹下分别创建 enter.xml 和 exit.xml 文件
// enter.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500">
<scale android:pivotX="0%p"
android:pivotY="0%p"
android:fromXScale="0%p"
android:toXScale="100%p"
android:fromYScale="0%p"
android:toYScale="100%p"/>
</set>
//exit.xml
<?xml version="1.0" enco
ding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1500">
<scale android:pivotX="0%p"
android:pivotY="0%p"
android:fromXScale="100%p"
android:toXScale="0%p"
android:fromYScale="100%p"
android:toYScale="0%p"/>
</set>
第二步:和使用系统动画一样 用起来就好了
启动时的设置
package com.wust.myanimation;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.BounceInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView tv_hello_world;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
评论