Android View创建和销毁调用的所有方法

本文详细解析了View组件的基本创建方法及关键属性操作,包括布局参数设置、焦点管理、状态判断等,同时介绍了View在不同系统事件(如触摸、屏幕可见性变化等)下的响应流程,为开发者提供全面的View组件使用指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

很久没有写东西了,今天来公司比较早,弄个小知识,了解View的动作,才能让它有更大的作为

View 的创建 

setOverScrollMode()

setLayoutParams()
requestLayout()
hasFocus()
hasTransientState()

isClickable()
isLongClickable()
getAccessibilityNodeProvider()
dispatchVisibilityChanged()
onVisibilityChanged()
dispatchVisibilityChanged()
onVisibilityChanged()
jumpDrawablesToCurrentState()
jumpDrawablesToCurrentState()
jumpDrawablesToCurrentState()
onAttachedToWindow()
jumpDrawablesToCurrentState()
isFocused()
onWindowVisibilityChanged()
refreshDrawableState()
drawableStateChanged()
getVisibility()
getLayoutParams()
onMeasure()
getSuggestedMinimumWidth()
getSuggestedMinimumHeight()
getLayoutParams()
getVisibility()
getLayoutParams()
layout()
isOpaque()
onSizeChanged()
isOpaque()
getMatrix()
isOpaque()
onLayout()
requestFocus()
forceLayout()
dispatchWindowFocusChanged()
onWindowFocusChanged()
refreshDrawableState()
 drawableStateChanged()
getVisibility()
getLayoutParams()
onMeasure()
getSuggestedMinimumWidth()
getSuggestedMinimumHeight()
getLayoutParams()
getVisibility()
getLayoutParams()
layout()
onLayout()
getLayerType()
getAnimation()
getLayerType()
computeScroll()
draw()
onDraw()
dispatchDraw()
hasOverlappingRendering()

点击View方法执行顺序

dispatchTouchEvent()
onFilterTouchEventForSecurity()
onTouchEvent()

下拉状态栏,会执行下面方法。
 

dispatchWindowFocusChanged()
onWindowFocusChanged()
isPressed()
isPressed()
refreshDrawableState()
drawableStateChanged()


返回键退出状态栏
 

dispatchWindowFocusChanged()
onWindowFocusChanged()
refreshDrawableState()
drawableStateChanged()


锁屏

onScreenStateChanged()
dispatchSaveInstanceState()

解屏
 

onScreenStateChanged()


旋转

dispatchSaveInstanceState()
onWindowVisibilityChanged()
onDetachedFromWindow()
destroyDrawingCache()
setOverScrollMode()
setLayoutParams()
requestLayout()
hasFocus()
hasTransientState()
isClickable()
isLongClickable()
getAccessibilityNodeProvider()
dispatchRestoreInstanceState()
dispatchVisibilityChanged()
onVisibilityChanged()
dispatchVisibilityChanged()
onVisibilityChanged()
jumpDrawablesToCurrentState()
jumpDrawablesToCurrentState()
jumpDrawablesToCurrentState()
onAttachedToWindow()
jumpDrawablesToCurrentState()
isFocused()
onWindowVisibilityChanged()
refreshDrawableState()
drawableStateChanged()
getVisibility()
getLayoutParams()
onMeasure()
getSuggestedMinimumWidth()
getSuggestedMinimumHeight()
getLayoutParams()
getVisibility()
getLayoutParams()
layout()
isOpaque()
onSizeChanged()
isOpaque()
getMatrix()
isOpaque()
onLayout()
requestFocus()
forceLayout()
dispatchWindowFocusChanged()
onWindowFocusChanged()
refreshDrawableState()
drawableStateChanged()
getVisibility()
getLayoutParams()
onMeasure()
getSuggestedMinimumWidth()
getSuggestedMinimumHeight()
getLayoutParams()
getVisibility()
getLayoutParams()
layout()
onLayout()
getLayerType()
getAnimation()
getLayerType()
computeScroll()
draw()
onDraw()
dispatchDraw()
hasOverlappingRendering()

退出
 

dispatchWindowFocusChanged()
onWindowFocusChanged()
isPressed()
isPressed()
refreshDrawableState()
drawableStateChanged()
dispatchWindowVisibilityChanged()
onWindowVisibilityChanged()
onDetachedFromWindow()
destroyDrawingCache()

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值