title: Calling requestLayout from a separate thread
body: <p>I have an OpenGL game loop (update+draw) on a GLSurfaceView.Renderer that runs on a separate thread than the thread that the GLSurfaceView subclass (which contains the renderer) was made.</p>
  
  <p>Sometimes, the update loop logic decides, "Hmm, we need to resize the view to half size". It then calls the GLSurfaceView view's requestLayout, and my onMeasure function would take care of the resizing.</p>
  
  <p>However, it turns out I'm not supposed to call requestLayout from any other thread other than the original thread that made the view hierarchy. I got the following exception:</p>
  
  <pre><code>E/AndroidRuntime( 3693): FATAL EXCEPTION: GLThread 3424
  E/AndroidRuntime( 3693): Process: com.android.gl2jni, PID: 3693
  E/AndroidRuntime( 3693): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
  E/AndroidRuntime( 3693):        at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6094)
  E/AndroidRuntime( 3693):        at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:857)
  E/AndroidRuntime( 3693):        at android.view.ViewGroup.invalidateChild(ViewGroup.java:4320)
  E/AndroidRuntime( 3693):        at android.view.View.invalidate(View.java:10935)
  
  &lt;snip&gt;
  </code></pre>
  
  <p>I tried using postInvalidate, but I think what I need is something closer to postRequestLayout(). However, there's only requestLayout().</p>
  
  <p>How do I trigger requestLayout, somehow?</p>
  
  <p>I'm not sure if this complicates things, but the view is owned by whatever runs the Input Method Service. Yep, it's an OpenGL based android keyboard, but that's another long story that might not be too relevant to this issue.</p>