Android 各类生命周期详解

Android 各类生命周期详解

目录

  • Android 各类生命周期详解
    • 目录
    • Activity的生命周期
      • 创建
      • 暂停
      • 恢复
      • 销毁
      • 屏幕旋转
    • Fragment的生命周期
      • 创建
      • 暂停
      • 恢复
      • 销毁
      • 屏幕旋转
    • ViewGroup生命周期
      • 创建
      • 暂停
      • 恢复
      • 销毁
      • 屏幕旋转
    • View生命周期
      • 创建
      • 暂停
      • 恢复
      • 销毁
      • 屏幕旋转
    • 综合
      • 创建
      • 暂停
      • 恢复
      • 销毁
      • 屏幕旋转
      • View Invalidate
      • View RequestLayout
      • ViewGroup Invalidate
      • ViewGroup RequestLayout
    • 总结
    • 附录
        • 测试源代码

Activity的生命周期

创建

MainActivity.onApplyThemeResource(MainActivity.java:89)
MainActivity.onCreate(MainActivity.java:39)
MainActivity.onAttachFragment(MainActivity.java:249)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onCreateView(MainActivity.java:501)
MainActivity.onContentChanged(MainActivity.java:519)
MainActivity.onSupportContentChanged(MainActivity.java:617)
MainActivity.onStart(MainActivity.java:52)
MainActivity.onPostCreate(MainActivity.java:435)
MainActivity.onTitleChanged(MainActivity.java:465)
MainActivity.onWindowAttributesChanged(MainActivity.java:392)
MainActivity.onStateNotSaved(MainActivity.java:568)
MainActivity.onResume(MainActivity.java:58)
MainActivity.onPostResume(MainActivity.java:441)
MainActivity.onResumeFragments(MainActivity.java:447)
MainActivity.onEnterAnimationComplete(MainActivity.java:285)
MainActivity.onAttachedToWindow(MainActivity.java:243)
MainActivity.onCreatePanelView(MainActivity.java:219)
MainActivity.onCreatePanelMenu(MainActivity.java:471)
MainActivity.onCreateOptionsMenu(MainActivity.java:64)
MainActivity.onPreparePanel(MainActivity.java:489)
MainActivity.onPrepareOptionsPanel(MainActivity.java:405)
MainActivity.onPrepareOptionsMenu(MainActivity.java:71)
MainActivity.onWindowFocusChanged(MainActivity.java:398)

暂停

MainActivity.onUserInteraction(MainActivity.java:386)
MainActivity.onUserLeaveHint(MainActivity.java:101)
MainActivity.onPause(MainActivity.java:429)
MainActivity.onWindowFocusChanged(MainActivity.java:398)
MainActivity.onCreateDescription(MainActivity.java:206)
MainActivity.onSaveInstanceState(MainActivity.java:453)
MainActivity.onStop(MainActivity.java:459)
MainActivity.onTrimMemory(MainActivity.java:380)

恢复

MainActivity.onStateNotSaved(MainActivity.java:568)
MainActivity.onRestart(MainActivity.java:77)
MainActivity.onStart(MainActivity.java:52)
MainActivity.onResume(MainActivity.java:58)
MainActivity.onPostResume(MainActivity.java:441)
MainActivity.onResumeFragments(MainActivity.java:447)
MainActivity.onWindowFocusChanged(MainActivity.java:398)
MainActivity.onEnterAnimationComplete(MainActivity.java:285)

销毁

MainActivity.onUserInteraction(MainActivity.java:386)
MainActivity.onKeyDown(MainActivity.java:477)
MainActivity.onUserInteraction(MainActivity.java:386)
MainActivity.onKeyUp(MainActivity.java:157)
MainActivity.onBackPressed(MainActivity.java:507)
MainActivity.onWindowFocusChanged(MainActivity.java:398)
MainActivity.onPause(MainActivity.java:429)
MainActivity.onStop(MainActivity.java:459)
MainActivity.onDestroy(MainActivity.java:417)
MainActivity.onDetachedFromWindow(MainActivity.java:279)

屏幕旋转

MainActivity.onTrimMemory(MainActivity.java:383)
MainActivity.onConfigurationChanged(MainActivity.java:516)
MainActivity.onPause(MainActivity.java:432)
MainActivity.onSaveInstanceState(MainActivity.java:456)
MainActivity.onStop(MainActivity.java:462)
MainActivity.onRetainCustomNonConfigurationInstance(MainActivity.java:546)
MainActivity.onDestroy(MainActivity.java:420)
MainActivity.onDetachedFromWindow(MainActivity.java:282)
MainActivity.onApplyThemeResource(MainActivity.java:92)
MainActivity.onCreate(MainActivity.java:40)
MainActivity.onAttachFragment(MainActivity.java:252)
MainActivity.onAttachFragment(MainActivity.java:264)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onContentChanged(MainActivity.java:522)
MainActivity.onSupportContentChanged(MainActivity.java:620)
MainActivity.onStart(MainActivity.java:55)
MainActivity.onAttachFragment(MainActivity.java:264)
MainActivity.onRestoreInstanceState(MainActivity.java:98)
MainActivity.onPostCreate(MainActivity.java:438)
MainActivity.onTitleChanged(MainActivity.java:468)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onStateNotSaved(MainActivity.java:571)
MainActivity.onResume(MainActivity.java:61)
MainActivity.onPostResume(MainActivity.java:444)
MainActivity.onResumeFragments(MainActivity.java:450)
MainActivity.onAttachedToWindow(MainActivity.java:246)
MainActivity.onCreatePanelView(MainActivity.java:222)
MainActivity.onCreatePanelMenu(MainActivity.java:474)
MainActivity.onCreateOptionsMenu(MainActivity.java:67)
MainActivity.onPreparePanel(MainActivity.java:492)
MainActivity.onPrepareOptionsPanel(MainActivity.java:408)
MainActivity.onPrepareOptionsMenu(MainActivity.java:74)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MainActivity.onTrimMemory(MainActivity.java:383)

Fragment的生命周期

创建

MyFragment.onAttach(MyFragment.java:138)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onGetLayoutInflater(MyFragment.java:120)
MyFragment.onCreateView(MyFragment.java:54)
MyFragment.onActivityCreated(MyFragment.java:126)
MyFragment.onStart(MyFragment.java:210)
MyFragment.onResume(MyFragment.java:204)

暂停

MyFragment.onPause(MyFragment.java:186)
MyFragment.onSaveInstanceState(MyFragment.java:60)
MyFragment.onStop(MyFragment.java:216)

恢复

MyFragment.onStart(MyFragment.java:210)
MyFragment.onResume(MyFragment.java:204)

销毁

MyFragment.onPause(MyFragment.java:186)
MyFragment.onStop(MyFragment.java:216)
MyFragment.onDestroyView(MyFragment.java:162)
MyFragment.onDestroy(MyFragment.java:150)
MyFragment.onDetach(MyFragment.java:168)

屏幕旋转

MyFragment.onConfigurationChanged(MyFragment.java:47)
MyFragment.onPause(MyFragment.java:187)
MyFragment.onSaveInstanceState(MyFragment.java:61)
MyFragment.onStop(MyFragment.java:217)
MyFragment.onDestroyView(MyFragment.java:163)
MyFragment.onDestroy(MyFragment.java:151)
MyFragment.onDetach(MyFragment.java:169)
MyFragment.onAttach(MyFragment.java:139)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onAttach(MyFragment.java:139)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onStart(MyFragment.java:211)
MyFragment.onStart(MyFragment.java:211)
MyFragment.onResume(MyFragment.java:205)
MyFragment.onResume(MyFragment.java:205)

ViewGroup生命周期

创建

MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)

暂停

MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)

恢复

MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)

销毁

MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)

屏幕旋转

MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)

View生命周期

创建

MyView.onFinishInflate(MyView.java:170)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

暂停

MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)

恢复

MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

销毁

MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onDetachedFromWindow(MyView.java:152)

屏幕旋转

MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onDetachedFromWindow(MyView.java:152)
MyView.onFinishInflate(MyView.java:170)
MyView.onFinishInflate(MyView.java:170)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onMeasure(MyView.java:188)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

综合

创建

MainActivity.onApplyThemeResource(MainActivity.java:92)
MainActivity.onCreate(MainActivity.java:40)
MainActivity.onAttachFragment(MainActivity.java:252)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onContentChanged(MainActivity.java:522)
MainActivity.onSupportContentChanged(MainActivity.java:620)
MainActivity.onStart(MainActivity.java:55)
MyFragment.onAttach(MyFragment.java:139)
MainActivity.onAttachFragment(MainActivity.java:264)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MyView.onFinishInflate(MyView.java:170)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onStart(MyFragment.java:211)
MainActivity.onPostCreate(MainActivity.java:438)
MainActivity.onTitleChanged(MainActivity.java:468)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onStateNotSaved(MainActivity.java:571)
MainActivity.onResume(MainActivity.java:61)
MainActivity.onPostResume(MainActivity.java:444)
MainActivity.onResumeFragments(MainActivity.java:450)
MyFragment.onResume(MyFragment.java:205)
MainActivity.onEnterAnimationComplete(MainActivity.java:288)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MainActivity.onAttachedToWindow(MainActivity.java:246)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MainActivity.onCreatePanelView(MainActivity.java:222)
MainActivity.onCreatePanelMenu(MainActivity.java:474)
MainActivity.onCreateOptionsMenu(MainActivity.java:67)
MainActivity.onPreparePanel(MainActivity.java:492)
MainActivity.onPrepareOptionsPanel(MainActivity.java:408)
MainActivity.onPrepareOptionsMenu(MainActivity.java:74)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

暂停

MainActivity.onUserInteraction(MainActivity.java:389)
MainActivity.onUserLeaveHint(MainActivity.java:104)
MainActivity.onPause(MainActivity.java:432)
MyFragment.onPause(MyFragment.java:187)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MainActivity.onCreateDescription(MainActivity.java:209)
MainActivity.onSaveInstanceState(MainActivity.java:456)
MyFragment.onSaveInstanceState(MyFragment.java:61)
MainActivity.onStop(MainActivity.java:462)
MyFragment.onStop(MyFragment.java:217)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyView.onVisibilityChanged(MyView.java:212)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyView.onVisibilityAggregated(MyView.java:362)
MainActivity.onTrimMemory(MainActivity.java:383)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyView.onVisibilityAggregated(MyView.java:362)

恢复

MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyView.onVisibilityAggregated(MyView.java:362)
MainActivity.onStateNotSaved(MainActivity.java:571)
MainActivity.onRestart(MainActivity.java:80)
MainActivity.onStart(MainActivity.java:55)
MyFragment.onStart(MyFragment.java:211)
MainActivity.onResume(MainActivity.java:61)
MainActivity.onPostResume(MainActivity.java:444)
MainActivity.onResumeFragments(MainActivity.java:450)
MyFragment.onResume(MyFragment.java:205)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyView.onVisibilityChanged(MyView.java:212)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyView.onVisibilityAggregated(MyView.java:362)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)
MainActivity.onEnterAnimationComplete(MainActivity.java:288)

销毁

MainActivity.onUserInteraction(MainActivity.java:389)
MainActivity.onKeyDown(MainActivity.java:480)
MainActivity.onUserInteraction(MainActivity.java:389)
MainActivity.onKeyUp(MainActivity.java:160)
MainActivity.onBackPressed(MainActivity.java:510)
MainActivity.onPause(MainActivity.java:432)
MyFragment.onPause(MyFragment.java:187)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyView.onVisibilityAggregated(MyView.java:362)
MainActivity.onStop(MainActivity.java:462)
MyFragment.onStop(MyFragment.java:217)
MainActivity.onDestroy(MainActivity.java:420)
MyFragment.onDestroyView(MyFragment.java:163)
MyView.onDetachedFromWindow(MyView.java:152)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)
MyFragment.onDestroy(MyFragment.java:151)
MyFragment.onDetach(MyFragment.java:169)
MainActivity.onDetachedFromWindow(MainActivity.java:282)

屏幕旋转

MainActivity.onConfigurationChanged(MainActivity.java:516)
MyFragment.onConfigurationChanged(MyFragment.java:47)
MyFragment.onConfigurationChanged(MyFragment.java:47)
MyFragment.onConfigurationChanged(MyFragment.java:47)
MainActivity.onPause(MainActivity.java:432)
MyFragment.onPause(MyFragment.java:187)
MyFragment.onPause(MyFragment.java:187)
MyFragment.onPause(MyFragment.java:187)
MainActivity.onSaveInstanceState(MainActivity.java:456)
MyFragment.onSaveInstanceState(MyFragment.java:61)
MyFragment.onSaveInstanceState(MyFragment.java:61)
MyFragment.onSaveInstanceState(MyFragment.java:61)
MainActivity.onStop(MainActivity.java:462)
MyFragment.onStop(MyFragment.java:217)
MyFragment.onStop(MyFragment.java:217)
MyFragment.onStop(MyFragment.java:217)
MainActivity.onRetainCustomNonConfigurationInstance(MainActivity.java:546)
MainActivity.onDestroy(MainActivity.java:420)
MyFragment.onDestroyView(MyFragment.java:163)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onDetachedFromWindow(MyView.java:152)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)
MyFragment.onDestroy(MyFragment.java:151)
MyFragment.onDetach(MyFragment.java:169)
MyFragment.onDestroyView(MyFragment.java:163)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onDetachedFromWindow(MyView.java:152)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)
MyFragment.onDestroy(MyFragment.java:151)
MyFragment.onDetach(MyFragment.java:169)
MyFragment.onDestroyView(MyFragment.java:163)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onDetachedFromWindow(MyView.java:152)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onDetachedFromWindow(MyFrameLayout.java:156)
MyFragment.onDestroy(MyFragment.java:151)
MyFragment.onDetach(MyFragment.java:169)
MainActivity.onDetachedFromWindow(MainActivity.java:282)
MainActivity.onApplyThemeResource(MainActivity.java:92)
MainActivity.onCreate(MainActivity.java:40)
MainActivity.onAttachFragment(MainActivity.java:252)
MyFragment.onAttach(MyFragment.java:139)
MainActivity.onAttachFragment(MainActivity.java:264)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onAttach(MyFragment.java:139)
MainActivity.onAttachFragment(MainActivity.java:264)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onAttach(MyFragment.java:139)
MainActivity.onAttachFragment(MainActivity.java:264)
MyFragment.onCreate(MyFragment.java:29)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onContentChanged(MainActivity.java:522)
MainActivity.onSupportContentChanged(MainActivity.java:620)
MainActivity.onStart(MainActivity.java:55)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MyView.onFinishInflate(MyView.java:170)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MyView.onFinishInflate(MyView.java:170)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MyView.onFinishInflate(MyView.java:170)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onAttach(MyFragment.java:139)
MainActivity.onAttachFragment(MainActivity.java:264)
MyFragment.onCreate(MyFragment.java:29)
MyFragment.onGetLayoutInflater(MyFragment.java:121)
MyFragment.onCreateView(MyFragment.java:54)
MainActivity.onCreateView(MainActivity.java:504)
MainActivity.onCreateView(MainActivity.java:504)
MyView.onFinishInflate(MyView.java:170)
MyFrameLayout.onViewAdded(MyFrameLayout.java:462)
MyFrameLayout.onFinishInflate(MyFrameLayout.java:174)
MyFragment.onViewCreated(MyFragment.java:223)
MyFragment.onActivityCreated(MyFragment.java:127)
MyFragment.onViewStateRestored(MyFragment.java:229)
MyFragment.onCreateAnimation(MyFragment.java:109)
MyFragment.onCreateAnimator(MyFragment.java:115)
MyFragment.onStart(MyFragment.java:211)
MyFragment.onStart(MyFragment.java:211)
MyFragment.onStart(MyFragment.java:211)
MyFragment.onStart(MyFragment.java:211)
MainActivity.onRestoreInstanceState(MainActivity.java:98)
MainActivity.onPostCreate(MainActivity.java:438)
MainActivity.onTitleChanged(MainActivity.java:468)
MainActivity.onWindowAttributesChanged(MainActivity.java:395)
MainActivity.onStateNotSaved(MainActivity.java:571)
MainActivity.onResume(MainActivity.java:61)
MainActivity.onPostResume(MainActivity.java:444)
MainActivity.onResumeFragments(MainActivity.java:450)
MyFragment.onResume(MyFragment.java:205)
MyFragment.onResume(MyFragment.java:205)
MyFragment.onResume(MyFragment.java:205)
MyFragment.onResume(MyFragment.java:205)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MyFrameLayout.onRtlPropertiesChanged(MyFrameLayout.java:348)
MyView.onRtlPropertiesChanged(MyView.java:344)
MainActivity.onAttachedToWindow(MainActivity.java:246)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onAttachedToWindow(MyFrameLayout.java:138)
MyFrameLayout.onWindowVisibilityChanged(MyFrameLayout.java:222)
MyFrameLayout.onVisibilityAggregated(MyFrameLayout.java:366)
MyFrameLayout.onVisibilityChanged(MyFrameLayout.java:216)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onAttachedToWindow(MyView.java:134)
MyView.onWindowVisibilityChanged(MyView.java:218)
MyView.onVisibilityAggregated(MyView.java:362)
MyView.onVisibilityChanged(MyView.java:212)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyFrameLayout.onSizeChanged(MyFrameLayout.java:210)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onSizeChanged(MyView.java:206)
MyView.onLayout(MyView.java:182)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MyFrameLayout.onRequestFocusInDescendants(MyFrameLayout.java:384)
MainActivity.onCreatePanelView(MainActivity.java:222)
MainActivity.onCreatePanelMenu(MainActivity.java:474)
MainActivity.onCreateOptionsMenu(MainActivity.java:67)
MainActivity.onPreparePanel(MainActivity.java:492)
MainActivity.onPrepareOptionsPanel(MainActivity.java:408)
MainActivity.onPrepareOptionsMenu(MainActivity.java:74)
MainActivity.onWindowFocusChanged(MainActivity.java:401)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyFrameLayout.onWindowFocusChanged(MyFrameLayout.java:53)
MyFrameLayout.onCreateDrawableState(MyFrameLayout.java:113)
MyView.onWindowFocusChanged(MyView.java:49)
MyView.onCreateDrawableState(MyView.java:109)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

View Invalidate

MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

View RequestLayout

MyView.onMeasure(MyView.java:188)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyView.onMeasure(MyView.java:188)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onLayout(MyView.java:182
MyView.onDraw(MyView.java:164)
MyView.onDrawForeground(MyView.java:278)

ViewGroup Invalidate

  • 无背景等属性时无日志

ViewGroup RequestLayout

MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onMeasure(MyFrameLayout.java:192)
MyFrameLayout.onLayout(MyFrameLayout.java:186)
MyView.onMeasure(MyView.java:188)
MyView.onLayout(MyView.java:182)

总结

  • 销毁的日志有一些KeyEvent的触发是由于点了Back键,希望不会造成误解
  • 在日志中可以发现onWindowFocusChanged这个方法是显示前的最后一个方法,可以重写这个方法,加入一些需要显示时触发的代码
  • ViewGroup和View的生命周期大部分都相同,但是仔细看的话会发现ViewGroup的onDraw方法没有触发,这是一个坑,在ViewGroup没有设置背景等属性时onDraw是不会触发的,故而不要轻易在ViewGroup的onDraw中添加代码,可以选择在ViewGroup的dispatchDraw中添加作为代替

附录

测试源代码

你可能感兴趣的:(Android)