Complex animation design series

  • Complex Animation Design -Android animation category

Complex Animation Design -Android Animation Category introduces the most common Android animation scenes, as a supplement, this article will further comb through the Android ‘motion effects’.

1. ‘Dynamic effects’ in Android depending on usage scenario

  1. The View animation
  2. The frame of animation
  3. Attribute animation

2. View the animation

  1. This article describes how to use the View animation to set the ‘Activity toggle effect ‘.
  2. There are two ways to set the Activity toggle effect using the View animation
    • Using the overridePendingTransition
    • Use the style
  3. Using the overridePendingTransition
    anim_activity_change_over_curr_enter:
    
            
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <alpha
            android:duration="2000"
            android:fromAlpha="0.0"
            android:toAlpha="1.0" />
        <translate
            android:duration="2000"
            android:fromXDelta="0"
            android:fromYDelta="100%"
            android:toXDelta="0"
            android:toYDelta="0" />
    </set>
    
    anim_activity_change_over_curr_exit:
    
            
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <alpha
            android:duration="2000"
            android:fromAlpha="1.0"
            android:toAlpha="0.0" />
        <translate
            android:duration="2000"
            android:fromXDelta="0"
            android:fromYDelta="0"
            android:toXDelta="0"
            android:toYDelta="100%" />
    </set>
    Copy the code
    jump(OverridePendingTransitionSecondActivity.class);
    overridePendingTransition(R.anim.anim_activity_change_over_curr_enter,R.anim.anim_activity_change_over_curr_exit);
    Copy the code
  4. Use the style
    1. First create the style in res/values/styles. XML and define the four animation effects for the Activity switch
      • ActivityOpenEnterAnimation is opening a new Activity, to show the new Activit perform animations
      • ActivityOpenExitAnimation is opening a new Activity, the current old Activit animation of execution
      • ActivityCloseEnterAnimation closed an activity, to show an activity performed on animation
      • ActivityCloseExitAnimation closed an activity, be closed activity execution of animation
      <style name="ActivityChangeAnim">
          <item name="android:activityOpenEnterAnimation">@anim/anim_activity_open_enter</item>
          <item name="android:activityOpenExitAnimation">@anim/anim_activity_open_exit</item>
          <item name="android:activityCloseEnterAnimation">@anim/anim_activity_close_enter</item>
          <item name="android:activityCloseExitAnimation">@anim/anim_activity_close_exit</item>
      </style>
      
      anim_activity_open_enter:
      
                
      <set xmlns:android="http://schemas.android.com/apk/res/android">
          <alpha
              android:duration="2000"
              android:fromAlpha="0.0"
              android:toAlpha="1.0" />
          <translate
              android:duration="2000"
              android:fromXDelta="0"
              android:fromYDelta="100%"
              android:toXDelta="0"
              android:toYDelta="0" />
      </set>
      
      anim_activity_open_exit:
      
                
      <set xmlns:android="http://schemas.android.com/apk/res/android">
          <alpha
              android:duration="2000"
              android:fromAlpha="1.0"
              android:toAlpha="0.0" />
          <translate
              android:duration="2000"
              android:fromXDelta="0"
              android:fromYDelta="0"
              android:toXDelta="0"
              android:toYDelta="100%" />
      </set>
      
      anim_activity_close_enter:
      
                
      <set xmlns:android="http://schemas.android.com/apk/res/android">
          <alpha
              android:duration="2000"
              android:fromAlpha="0.0"
              android:toAlpha="1.0" />
          <translate
              android:duration="2000"
              android:fromXDelta="100%"
              android:fromYDelta="0"
              android:toXDelta="0"
              android:toYDelta="0" />
      </set>
      
      anim_activity_close_exit:
      
                
      <set xmlns:android="http://schemas.android.com/apk/res/android">
          <alpha
              android:duration="2000"
              android:fromAlpha="0.0"
              android:toAlpha="1.0" />
          <translate
              android:duration="2000"
              android:fromXDelta="0"
              android:fromYDelta="0"
              android:toXDelta="100%"
              android:toYDelta="0" />
      </set>
      Copy the code
    2. In the Application or the Activity want to use the theme, through the android: windowAnimationStyle reference style just created
      <style name="StyleActivityChangeTheme" parent="Theme.AppCompat.Light.DarkActionBar">
          <item name="android:windowAnimationStyle">@style/ActivityChangeAnim</item>
      </style>
      Copy the code
    3. Apply this theme in androidmanifest.xml, which can be referenced only for specific activities.
      <activity
          android:name=".activity.animation.activitychange.UseStyleThemeSecondActivity"
          android:theme="@style/StyleActivityChangeTheme" />
      <activity
          android:name=".activity.animation.activitychange.UseStyleThemeFirstActivity"
          android:theme="@style/StyleActivityChangeTheme" />
      Copy the code

3. Property animation

  • Android. Animation (7) – android: animateLayoutChanges properties and LayoutTransition
  • LayoutTransition Layout animation is simple to use
  • Android Animation completely summarizes (3) Animator and LayoutTransition
  • LayoutTransiton implements simple record buttons

LayoutTransition

N

  • Animation and transitions
  • How many animations are there on Android? Tell you exactly!
  • Android- animation-set The above blog code