各种动画/动效实现方案

246 阅读1分钟

待看

  1. Android修炼系列(十七),Activity过渡动画指南
  2. Activity跳转动画及View无缝衔接,了解一下?
  3. 高逼格Android转场动画,轻松实现掘金用户头像转场动画
  4. android转场动画,让你的APP瞬间绚丽起来
  5. Android转场动画的前世今生

1. Activity转场动画

fun activityChangeAnim(view: View) {
    try {
        val intent = Intent()
        intent.setPackage("com.example.targetapp")
        intent.component = ComponentName("com.example.targetapp","com.example.targetapp.MainActivity")
        startActivity(intent)
    } catch (e: Exception) {
        Log.e("MainActivity","jump another app page fail", e)
    }
    finish()
    overridePendingTransition(R.anim.fade_in,R.anim.fade_out)
}

fade_in :

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromAlpha="0.0"
    android:interpolator="@anim/interpolator_activity_jump"
    android:toAlpha="1.0" />

fade_out :

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="500"
    android:fromAlpha="1.0"
    android:interpolator="@anim/interpolator_activity_jump"
    android:toAlpha="0.0" />