title: onlayout not be called
body: <p>Here is my code to set my 3*2 layout, and when I initialize the view in the onCreateView() method, and use setX(100) with the second following code, everything works as I thought, i.e. the whole 3*2 view move right for 100 pixel. When I add touch event listener, and change the view position with setX(100) there, then the onlayout() is not called, it is just like a 3*1 layout. </p>
  
  <p>So how to call this onLayout when I received a touch event?</p>
  
  <pre><code>protected void onLayout(boolean changed, int l, int t, int r, int b) {
      super.onLayout(changed, l, t, r, b);
      int mTotalHeight = 0;  
      int mTotalWidth = 0;
      int childCount = getChildCount();  
      for (int i = 0; i &lt; childCount; i++) {  
          View childView = getChildAt(i);  
          int measureHeight = childView.getMeasuredHeight();  
          int measuredWidth = childView.getMeasuredWidth();  
          childView.layout(mTotalWidth, mTotalHeight, mTotalWidth+measuredWidth, mTotalHeight + measureHeight);  
          mTotalWidth += measuredWidth;
          if (i%2 == 1) {
              mTotalWidth=0;
              mTotalHeight += measureHeight;  
          }
      }
  }
  </code></pre>
  
  <p>Here is my touch listener:</p>
  
  <pre><code>    public boolean onTouchEvent(MotionEvent event) {
              PointF curr = new PointF(event.getX(), event.getY());
              switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                  originalF = curr;
                  break;
  case MotionEvent.ACTION_MOVE:
      if ((curr.x-originalF.x)&lt;screenWidth) {
          for (MapView mapView : allViews) {
            mapView.setX(100)
          mapView.requestLayout();
          mapView.forceLayout();
         }
          this.invalidate();
  </code></pre>
  
  <p>and I checked android documents, which said onlayout() should be called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.</p>
  
  <p>I think my view Code do not has too much relation with that, but I will still paste them here.</p>
  
  <pre><code>private void init() {
      // TODO Auto-generated method stub
      Bitmap b = Bitmap.createBitmap(256, 256, Bitmap.Config.ARGB_8888);
       c = new Canvas(b);
       original = BitmapFactory.decodeResource(getResources(),R.drawable.placeholder);
       getScreenSize();
       final int canvasWidth = c.getWidth();
       final int canvasHeight = c.getHeight();
       Log.d(VIEW_LOG_TAG, "this new view's width is="+canvasWidth
               +"screen height is"+canvasHeight);     
  }
  
  @SuppressLint("NewApi")
  private void getScreenSize() {
      WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
      Display display = wm.getDefaultDisplay();
      try{
          Point size = new Point();
          display.getSize(size);
          screenWidth = size.x;
          screenHeight = size.y;
          Log.d(VIEW_LOG_TAG, "screen width is="+screenWidth
                  +"screen height is"+screenHeight);      
          }catch(NoSuchMethodError e){
              Log.d(VIEW_LOG_TAG, "not such method in getscreensize(", e);
          }
  }
  
      @Override
      protected void onDraw(Canvas canvas) {
           if (placeHolder != null) {
               canvas.drawBitmap(placeHolder, 0, 0, null);
          } 
      }
  
      //      stretch the image to the suitable size with parent MeasureSpec Param.
      @Override
      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          super.onMeasure(widthMeasureSpec, heightMeasureSpec);
          parentWidth = MeasureSpec.getSize(widthMeasureSpec);
          parentHeight = MeasureSpec.getSize(heightMeasureSpec);
          MeasureSpec.makeMeasureSpec(parentWidth, MeasureSpec.UNSPECIFIED);
      //     Log.d("this time", "parentSize is"+parentWidth+parentHeight);
             this.setMeasuredDimension(parentWidth, parentHeight);        //because just set the parent size, so indeed no effect here.
      }
  
  public void setMap(Bitmap bitmap) {
      //placeHolder = bitmap;
      placeHolder =Bitmap.createScaledBitmap(bitmap, parentWidth, parentHeight, true);
      invalidate();
  }   
  </code></pre>
  
  <p>In addition to that, I use </p>
  
  <pre><code>this.requestLayout();
  this.forceLayout();
  </code></pre>
  
  <p>but they did not make sense. </p>
  
  <p>May I address my main question again, how to call this onlayout() method?</p>