Custom Views Placed Into a Gallery Layout Appear Too Large
<p>I want to display a series of my own descendent class of View in a Gallery layout but when it is displayed, each of my custom views in the gallery is too large i.e. they exceed the border.</p>

<p>I've set (in XML) the background for each view as <code>"android:galleryItemBackground"</code> and handle onMeasure() etc in my descendent View class but for some reason my view is always drawn larger than the background.</p>

<p>Could anyone give me any idea what else I need to implement in my custom view class?</p>

<p>Thanks</p>

<p>The onDraw() method is here:</p>

<pre><code>protected void onDraw(Canvas canvas){


        /* Draw dial scale-arc */
        canvas.drawArc(scaleArcRect, scaleArcStart, scaleArcSweep, false, scaleArcPaint);
        canvas.drawArc(innerScaleArcRect, scaleArcStart, scaleArcSweep, false, innerScaleArcPaint);
        /* Draw the scale-arc ticks */
        drawScaleTicks(canvas);

        /* Add text to dial */
        //canvas.drawText(scaleFactorText, sFactorTextRect.left, sFactorTextRect.bottom, scaleTextPaint);

        drawScaleLegend(canvas);

        /*Draw the pointer */
        canvas.save();
        canvas.rotate(drawAngle,this.viewWidth/2,this.viewHeight/2);
        canvas.drawPath(pointerPath, pointerPaint);
        canvas.restore();


        //canvas.drawText(scaleFactorText, sFactorTextRect.left,this.viewHeight/2, scaleTextPaint);

        /* Update position feedback variables */
        actualAngle = drawAngle;

        /* signal to compute thread that the position has been updated */
        isCommanded  = false;
    }
</code></pre>
