onAttachedToWindow () 和 onDetachedFromWindow () 生命周期
今天在看第三方开源框架使用设计模式的相关书籍是,发现有一些第三方框架内部使用到了onAttachedToWindow来做了很多文章。本文我们一起了解一下,onAttachedToWindow调用的时机。
什么时候被调用的?
我们先看一下方法说明
/ * This is called when the view is attached to a window. At this point it * has a Surface and will start drawing. Note that this function is * guaranteed to be called before {@link #onDraw(android.graphics.Canvas)}, * however it may be called any time before the first onDraw -- including * before or after {@link #onMeasure(int, int)}. * * @see #onDetachedFromWindow() */ @CallSuper protected void onAttachedToWindow(