android中view的生命周期
2016-03-22 17:17
417 查看
请参见:http://ndquangr.blogspot.jp/2013/04/android-view-lifecycle.html
Category | Methods | Description |
---|---|---|
Creation | Constructors | There is a form of the constructor that are called when the view is created from code and a form that is called when the view is inflated from a layout file. The second form should parse and apply any attributes defined in the layout file. |
| Called after a view and all of its children has been inflated from XML. | |
Layout |
| Called to determine the size requirements for this view and all of its children. |
| Called when this view should assign a size and position to all of its children. | |
| Called when the size of this view has changed. | |
Drawing |
| Called when the view should render its content. |
Eventprocessing |
| Called when a new hardware key event occurs. |
| Called when a hardware key up event occurs. | |
| Called when a trackball motion event occurs. | |
| Called when a touch screen motion event occurs. | |
Focus |
| Called when the view gains or loses focus. |
| Called when the window containing the view gains or loses focus. | |
Attaching |
| Called when the view is attached to a window. |
| Called when the view is detached from its window. | |
| Called when the visibility of the window containing the view has changed. |
* [改变可见性] * --> 构造View * --> onFinishInflate * --> onAttachedToWindow * --> onMeasure * --> onSizeChanged * --> onLayout * --> onDraw * --> onDetackedFromWindow * * * 1、onFinishInflate() 当View中所有的子控件均被映射成xml后触发 。 2、onMeasure( int , int ) 确定所有子元素的大小 。 3、onLayout( boolean , int , int , int , int ) 当View分配所有的子元素的大小和位置时触发 。 4、onSizeChanged( int , int , int , int ) 当view的大小发生变化时触发 。 5、onDraw(Canvas) view渲染内容的细节。 6、onKeyDown( int , KeyEvent) 有按键按下后触发 。 7、onKeyUp( int , KeyEvent) 有按键按下后弹起时触发 。 8、onTrackballEvent(MotionEvent) 轨迹球事件 。 9、onTouchEvent(MotionEvent) 触屏事件 。 10、onFocusChanged( boolean , int , Rect) 当View获取或失去焦点时触发 。 11、onWindowFocusChanged( boolean ) 当窗口包含的view获取或失去焦点时触发 。 12、onAttachedToWindow() 当view被附着到一个窗口时触发 。 13、onDetachedFromWindow() 当view离开附着的窗口时触发,Android123提示该方法和 onAttachedToWindow() 是相反的。 14、onWindowVisibilityChanged( int ) 当窗口中包含的可见的view发生变化时触发。
相关文章推荐
- android的Shader
- android之自定义UncaughtExceptionHandler类来处理未捕获异常
- TextView内容太长怎么办?
- android关于canvas,path,paint非常好的讲解
- ANDROID ASSET STUDIO
- 从网上down下来的Android Studio 工程 打开报sdk location not found错误的解决办法
- 理解Android Support Library
- MQTT+ApolloServer实现Android的消息推送功能
- Android编程中的5种数据存储方式
- SVN:MAC SVN Android studio不能提交.so文件
- Android 通讯录增删改查
- android自定义view之自定义容器
- Android学习之DragEvent
- android 4.4 系统永不休眠
- 76、android:supportsRtl 和 android:layout_marginEnd
- Android自定义控件之圆形/圆角的实现代码
- WebView---Android与js交互实例
- Android 两个Activity之间传递数据及返回
- Ubuntu 14.04 编译 Android 4.2.2 for Tiny4412
- Android API 等级与Android版本对应关系