title: Onlayout method on custom layout extending RelativeLayout
body: <p>What is the proper way to override onLayout method in a custom layout extending the RelativeLayout?
  I'm trying to place all views in sort of a table. The idea is to fill one row with ImageViews until it's full and then continue in the new row.</p>
  
  <pre><code>@Override
  protected void onLayout(boolean changed, int l, int t, int r, int b) {
          super.onLayout(changed, l, t, r, b);
  
          int idOfViewToTheLeft = 1;
  
          RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(getContext(),);
  
          ImageView bookmark;
          for(int counter = 1; counter &lt; getChildCount(); counter++) {
              bookmark = (ImageView) findViewById(counter);
              if(counter &gt; 1) {
                 if(this.getWidth() &gt; (bookmark.getLeft() + bookmark.getWidth())) {
                     params.addRule(RelativeLayout.RIGHT_OF, bookmark.getId() - 1);
                 } else {
                     params.addRule(RelativeLayout.BELOW, idOfViewToTheLeft);
                     idOfViewToTheLeft = bookmark.getId();
                 }
              }
  
              bookmark.setScaleType(ScaleType.CENTER_CROP);
          }
      }
      }
  </code></pre>