Android Activity 的生命周期和Fragment 的生命周期我们都知道。但是对于视图有什么等价的吗?
例如,这可能有助于构建自定义视图或深入了解 Android 上非常常见且通常隐藏的图形操作。
提前致谢 !
Android Activity 的生命周期和Fragment 的生命周期我们都知道。但是对于视图有什么等价的吗?
例如,这可能有助于构建自定义视图或深入了解 Android 上非常常见且通常隐藏的图形操作。
提前致谢 !
它不是官方文件,但最近出现在 Google+ 上。评论也有很好的讨论和一些详细的解释。
在这里,我创建了扩展 View 的自定义视图。然后在每个方法中写入日志。这里调用方法的顺序:
运行调试
时 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
on
VisibilityAggregated
refreshDrawableState
drawableStateChanged
onCreateDrawableState
isFocused
hasWindowFocus
getVisibility
onMeasure
getSuggestedMinimumWidthVi
getMinimum
_
_
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
使用此视图打开活动:
onScreenStateChanged
getLayoutDirection
getAnimation
getLayerType
getVisibility
getVisibility
getVisibility
layout
getVisibility
dispatchWindowFocusChanged
onWindowFocusChanged
refreshDrawableState
drawableStateChanged
onCreateDrawableState
isFocused
hasWindowFocus