[Android] View 생성시 주요 Method 호출 순서

Test는 Button Class를 extends 한 CustomButton 으로 진행.

1. Constructor()

------ View 기본 설정 ------
2. onFinishInflate()
3. setLayoutParams()
4. requestLayout()
5. invalidate()

------ Window에 Attach ------
6. onAttachedToWindow()
7. invalidate()
8. onWindowVisibilityChanged(int visibility)
   : attach 된 Window의 Visibility 변경
9. onVisibilityChanged()  [1번째 호출]
   : View의 Visibility 변경
10. refreshDrawableState()
11. onCreateDrawableState()
12. dispatchVisibilityChanged()
13. onVisibilityChanged() [2번째 호출]
14. invalidate()
15. dispatchVisibilityChanged()
16. onVisibilityChanged() [3번째 호출]
17. invalidate()
18. scrollTo() [1번째 호출]
19. onMeasure()
20. dispatchApplyWindowInsets()
21. onApplyWindowInsets()
22. fitSystemWindows()
23. dispatchApplyWindowInsets()
24. onApplyWindowInsets()
25. fitSystemWindows()
27. scrollTo() [2번째 호출]
28. onMeasure()
29. getSuggestedMinimumHeight()
30. scrollTo() [3번째 호출]
31. onMeasure()
32. layout()
33. onSizeChanged()
 : H : 192, T : 76 (이 시점부터 getHeight()와 getTop()으로 값을 가져올 수 있다.)
34. onLayout()
35. setOnClickListener() // Data Binding 사용시
36. draw()
37. invalidate()
38. onDraw()
39. dispatchDraw()
40. onDrawForeground()
41. draw()
42. onDraw()
43. dispatchDraw()
44. onDrawForeground()
45. dispatchWindowFocusChanged()
46. refreshDrawableState()
47. onCreateDrawableState()
48. scrollTo()  [4번째 호출] [onMeasure()와는 함께 호출된다]
49. onMeasure()
50. layout()
51. onLayout()
52. draw()
53. onDraw()
54. dispatchDraw()
55. onDrawForeground()

댓글

이 블로그의 인기 게시물

[Android] DataBinding의 동작방식 - 4. include Tag 혹은 ViewStub 사용시의 Binding

[Android] Retrofit2, OkHttpClient Method 정리

[Android] Layout별 성능 비교[Measure 호출횟수 비교] (LinearLayout vs RelativeLayout vs ConstraintLayout)