1, there are several ways to implement view update in Android?
Do you know? In fact, there are two ways to implement view updates in Android, one is invalidate, and the other is Postinvalidate, where the former is used in the UI thread itself, while the latter is used in a non-UI thread.
What do you say? Android provides the Invalidate method for interface refresh, but invalidate cannot be called directly in the thread because he is violating the single-threaded model: Android UI operations are not thread-safe, and these operations must be called in the UI thread. In view of this, if you want to use invalidate refresh, then we have to cooperate with the use of handler, so that asynchronous non-UI thread to go to the UI thread call, if you want to use in a non-UI thread directly to call the Postinvalidate method, This eliminates the hassle of using handler.
2. When is requestlayout used?
When the view determines that it is no longer suitable for an existing zone, the view itself calls this method to require the parent view (the parents) to re-invoke his onmeasure onlayout to reset his position. This is especially appropriate when the view's layoutparameter has changed and its value has not been applied to the view.
Requestlayout Invalidate Postinvalidate