title: How to extend a complex Android view like the GridView?
body: <h2>Background:</h2>
  
  <p>I'm looking for a way to extend the <code>GridView</code> I need implement a col- and row-span like in HTML. I have hunderds of elements so I cannot use e.g. a <code>TableLayout</code>. However that would be <em>too localized</em>. So far I reduce the question to <strong>how to extend the GridView?</strong></p>
  
  <h2>What I have tried and where I have failed:</h2>
  
  <p>My first approach was to look which methods I need to replace and I found some private methods which cannot be overriden. So I tried to copy the hole source code from the <code>GridView</code> to a new class called <em>CustomGrid</em>. That was a terrible failure since I cannot access the <code>com.android.internal.R</code> class.</p>
  
  <p>Then I dropped that idea and looked if I can normal extend the class and replace all the private methods with custom copies. I took a pen and build a huge tree where all methods are used.</p>
  
  <p>After I found all references I tried to extend the class <em>normal</em> and I added the first method:</p>
  
  <pre><code>private View fillDown(int pos, int nextTop) {
      View selectedView = null;
  
      int end = (mBottom - mTop);
      if((mGroupFlags &amp; CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
          end -= mListPadding.bottom;
      }
  
      // ...
  </code></pre>
  
  <p>Here is my next problem that member variables <code>mBottom</code> and <code>mTop</code> are unknown. I digged a little through the sources and found them finally in the <code>View</code> class, but unfortunately they are hidden.</p>
  
  <pre><code>/**
   * The distance in pixels from the top edge of this view's parent
   * to the bottom edge of this view.
   * {@hide}
   */
  @ViewDebug.ExportedProperty(category = "layout")
  protected int mBottom;
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>How can I extend the <code>GridView</code> without hitting that lamentations and without the usage of massive reflection? I mean it seems to be impossible to write that as a pure custom control.</p>