Android动画相关 -- 转场动画调试

我们经常会遇到转场动画不对的问题,那么如何调试转场动画呢?

1. 要动态打开window的调试

dumpsys window -d list

可以看到
2 . DEBUG_ANIM = false
打开window调试

	dumpsys window -d enable 2

关闭调试

	dumpsys window -d disable 2

2. 查看当前使用的动画

搜索 applyAnimation: anim=

WindowManager: applyAnimation: anim=android.view.animation.AnimationSet@e7b72c5 animAttr=0x8 transit=TRANSIT_TASK_OPEN isEntrance=true

可以看到 animAttr=0x8,可以对应源码 WindowAnimation_taskOpenEnterAnimation
			   transit=TRANSIT_TASK_OPEN 

3. 源码中对应的动画

AppTransition.java

  Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, int uiMode,
          int orientation, Rect frame, Rect displayFrame, Rect insets,
          @Nullable Rect surfaceInsets, boolean isVoiceInteraction, boolean freeform,
          int taskId) {
	...
	switch (transit) {
		case TRANSIT_ACTIVITY_OPEN:
                    animAttr = enter
                    ? WindowAnimation_activityOpenEnterAnimation 
                            : WindowAnimation_activityOpenExitAnimation;
             break;
             ...
        case TRANSIT_TASK_OPEN: // 0x08
                    animAttr = enter
                            ? WindowAnimation_taskOpenEnterAnimation // 0x08
                            : WindowAnimation_taskOpenExitAnimation;
             ...
	}
	if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
                    "applyAnimation:"
                    + " anim=" + a
                    + " animAttr=0x" + Integer.toHexString(animAttr)
                    + " transit=" + appTransitionToString(transit) + " isEntrance=" + enter
                    + " Callers=" + Debug.getCallers(3));
  }

猜你喜欢

转载自blog.csdn.net/LHshooter/article/details/107409161
今日推荐