Is there any graphical representation of Android views lifecycle (a state diagram)? [closed]

喜欢而已 提交于 2019-12-03 01:09:56

问题


We all know about the Android Activity's life cycle and Fragment's life cycles. But is there anything equivalent for views ?

This could help, for instance, building custom views or give an in-depth look at a very common and often hidden graphic operation on Android.

Thanks in advance !


回答1:


It isn't an official document, but this recently came up on Google+. The comments also have a good discussion with some detailed explanation.




回答2:


Here I created custom view that extends View. Then wrote logs in each method. Here the order of called methods:
When run debugging
setOverScrollMode
setOverScrollMode
onFinishInflate
setLayoutParams
getLayoutDirection
requestLayout
hasFocus
hasTransientState
getVisibility
getLayoutDirection
getLayoutDirection
canResolveLayoutDirection
getLayoutDirection
canResolveTextDirection
isLayoutDirectionResolved
isLayoutDirectionResolved
getLayoutDirection
getLayoutDirection
isLayoutDirectionResolved
isTextDirectionResolved
isTextAlignmentResolved
getLayoutDirection
jumpDrawablesToCurrentState
jumpDrawablesToCurrentState
jumpDrawablesToCurrentState
jumpDrawablesToCurrentState
jumpDrawablesToCurrentState
jumpDrawablesToCurrentState
getVisibility
onAttachedToWindow
jumpDrawablesToCurrentState
getBackground
isFocused
isShown
onVisibilityAggregated
refreshDrawableState
drawableStateChanged
onCreateDrawableState
isFocused
hasWindowFocus
getVisibility
onMeasure
getSuggestedMinimumWidth
getSuggestedMinimumHeight
getVisibility
getVisibility
onMeasure
getSuggestedMinimumWidth
getSuggestedMinimumHeight
getVisibility
getVisibility
layout
isOpaque
onSizeChanged
getBackground
isOpaque
getMatrix
isOpaque
isHardwareAccelerated
getZ
getElevation
getTranslationZ
onLayout
getVisibility
getAnimation
getLayerType
getLayerType
computeScroll
draw
onDraw
dispatchDraw
onDrawForeground
hasOverlappingRendering
dispatchWindowFocusChanged
onWindowFocusChanged
refreshDrawableState
drawableStateChanged
onCreateDrawableState
isFocused
hasWindowFocus

Opening activity with this view:
onScreenStateChanged
getLayoutDirection
getAnimation
getLayerType
getVisibility
getVisibility
getVisibility
layout
getVisibility
dispatchWindowFocusChanged
onWindowFocusChanged
refreshDrawableState
drawableStateChanged
onCreateDrawableState
isFocused
hasWindowFocus



来源:https://stackoverflow.com/questions/13146765/is-there-any-graphical-representation-of-android-views-lifecycle-a-state-diagra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!