title: Vertical Scroll and Horizontal Scroll Android
body: <p>I have a class to display a table, and I want it to be Horizontally and Vertically Scrollable, I've seen a few solutions but I can't implement them, I put my view in a HorizontalScrollView, and that let me do the Horizontal Scroll, now I'm trying to set that HorizontalScrollView as a child of a ScrollView. something like this.</p>
  
  <pre><code>    ApuestasScoreCard draw;
  
      public class ApuestasScore extends Activity {
       @Override
       protected void onCreate(Bundle savedInstanceState) {
  
       super.onCreate(savedInstanceState);
  
       draw = new ApuestasScoreCard(this);
       draw.setBackgroundColor(Color.WHITE);
  
           ScrollView sv = new ScrollView(this)
       HorizontalScrollView hsv = new HorizontalScrollView(this);
           sv.addView(hsv);
       hsv.addView(draw);
  
       setContentView(hsv);
     }
  </code></pre>
  
  <p>then in my View class, I implement the OnMeasure() method to render the View. my question is: Is this a solution or what i'm trying to do is imposible. by the way, when i run this solution the logcat says:</p>
  
  <pre><code>java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  </code></pre>
  
  <p>here is my View class</p>
  
  <pre><code>public class ApuestasScoreCard extends View {
  ApuestasScore apuestas;
  
  public ApuestasScoreCard(Context context) {
      super(context);
      this.apuestas = (ApuestasScore) context;
      setFocusable(true);
      setFocusableInTouchMode(true);
  
              //..Not Important Code
  
   /* (non-Javadoc)
   * @see android.widget.HorizontalScrollView#onMeasure(int, int)
   */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
      // TODO Auto-generated method stub
      super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  
          int width = MeasureSpec.getSize(widthMeasureSpec+2000);
          int height = MeasureSpec.getSize(heightMeasureSpec+500);
          setMeasuredDimension(width, height);
  
  }
  
      @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
      width = w / 26f;
      height = h / 29f;
      width2 = w / 6.5f;
      height2 = h / 5f;
      getRect(selX, selY, selRect);
  
      super.onSizeChanged(w, h, oldw, oldh);
  }
  
      @Override
  protected void onDraw(Canvas canvas) {
      // Draw the background...FFFF00 23F607
  
  
  
              for (int i = 0; i &lt; 29; i++) {
                  if (i &lt; 3) {
                      canvas.drawLine(0, i * height, getWidth(), i * height, light);// Horizontales
  
                      canvas.drawLine(0, i * height + 1, width * 2, i * height + 1,
                              hilite);
                  }
                  if (i == 2 || i == 5 || i == 8 || i == 11 || i == 14 || i == 17
                          || i == 20 || i == 23 || i == 26 || i == 29) {
                      canvas.drawLine(0, i * height, getWidth(), i * height, dark);// Horizontales
  
                      canvas.drawLine(0, i * height + 1, getWidth(), i * height + 1,
                              hilite);
                  }
              }
              for (int i = 0; i &lt; 29; i++) {
  
                  canvas.drawLine(width * 2, i * height, getWidth() + 100,
                          i * height, light);// Horizontales
  
                  canvas.drawLine(width * 2, i * height + 1, getWidth() + 100, i
                          * height + 1, hilite);
  
                  if (i &gt; 1 &amp;&amp; i &lt; 12) {
                      canvas.drawLine(i * width, 0, i * width, getHeight(), light);
  
                      canvas.drawLine(i * width + 1, 0, i * width + 1, getHeight(),
                              hilite);
                  }
      }
  
  }
      }
  </code></pre>