Drawing inconstency before long click is released
<p>This program draws rectangles, each one is its own view.  Long-clicking on a rectangle should cause it to become selected (and the previous selected rectangle to become deselected).  The selected rectangle shows a red border around the edge with a width based on the density.  It seems to work well enough, except that after clicking the rectangle and holding it (but before releasing your finger) the red border is drawn incorrectly.  Once you release your finger it draws fine.  I have only one drawing routine in the rectangle view:</p>

<pre><code>protected void onDraw( Canvas canvas )
{       
    super.onDraw( canvas );
    final int m = 0;

    Paint paint = new Paint( Paint.ANTI_ALIAS_FLAG );
    paint.setColor( 0xFFBBBBBB );
    paint.setStyle( Paint.Style.FILL );
    canvas.drawRect( layoutLeft, layoutTop, layoutRight, layoutBottom, paint );

    if( isSelected() )
    {
        paint.setColor( 0xFFFF0000 );
    }
    else
    {
        paint.setColor( 0xFFFFFFFF );
    }

    paint.setStyle( Paint.Style.STROKE );
    paint.setStrokeWidth( lineWidth );
    canvas.drawRect( layoutLeft + m, layoutTop + m, layoutRight - m, layoutBottom - m, paint );
}
</code></pre>

<p>'lineWidth' is defined this way:</p>

<pre><code>    Resources resources = context.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    this.lineWidth = 4 * metrics.density;
</code></pre>

<p>I have some lovely, very helpful screenshots that I'm prevented from posting because I'm a new user, so please bear with my written description of the problem:</p>

<p>The first call to 'canvas.drawRect', with paint style = FILL, draws entirely within the dimensions passed in.  The second call, with paint style = STROKE, draws <em>on</em> the line rather than <em>inside</em> the lines, so that the modified area is bigger than the area defined by the parameters passed to the call.</p>

<p>The problem is that before you release your finger, the invalidated region includes only the area defined by the parameters passed to the call.  Thus, some of the STROKE-style border gets redrawn and some of it doesn't.  After you release your finger the invalidated region includes all of the modified area.</p>

<p>My questions are:  Is this a bug?  Shouldn't the invalidated area be the same both before and after the release?  I can compensate (by setting <code>m = 2</code>, thus drawing the border rectangle a little smaller so that it all fits within the invalidated region), but why is this necessary?  Is this according to design, or is there a problem I should report?</p>
