requestLayout(): 重新布局整個ViewTree,開始調用measure()方法。 requestLayout()是view的方法,view也可以調用該方法。
Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass.invalidate(): 如果當前View可見,onDraw()方法將會被調用。
Invalidate the whole view. If the view is visible, onDraw() will be called at some point in the future.This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().在寫SimpleIndicator時,并不是一定不會走onMeasure()方法,在某種條件下會走該方法的。可以搜其他的源碼分析文章,具體查看。源碼分析
新聞熱點
疑難解答