|
8 | 8 | import android.graphics.PointF;
|
9 | 9 | import android.graphics.Rect;
|
10 | 10 | import android.graphics.RectF;
|
| 11 | +import android.graphics.Region; |
11 | 12 | import android.graphics.Typeface;
|
12 | 13 | import android.support.annotation.Nullable;
|
13 | 14 | import android.support.v4.view.GestureDetectorCompat;
|
@@ -438,23 +439,23 @@ private void initTextTimeWidth() {
|
438 | 439 | protected void onDraw(Canvas canvas) {
|
439 | 440 | super.onDraw(canvas);
|
440 | 441 |
|
| 442 | + // Hide everything in the first cell (top left corner). |
| 443 | + canvas.drawRect(0, 0, mTimeTextWidth + mHeaderColumnPadding * 2, mHeaderTextHeight + mHeaderRowPadding * 2, mHeaderBackgroundPaint); |
| 444 | + |
441 | 445 | // Draw the header row.
|
442 | 446 | drawHeaderRowAndEvents(canvas);
|
443 | 447 |
|
444 | 448 | // Draw the time column and all the axes/separators.
|
445 | 449 | drawTimeColumnAndAxes(canvas);
|
446 |
| - |
447 |
| - // Hide everything in the first cell (top left corner). |
448 |
| - canvas.drawRect(0, 0, mTimeTextWidth + mHeaderColumnPadding * 2, mHeaderTextHeight + mHeaderRowPadding * 2, mHeaderBackgroundPaint); |
449 |
| - |
450 |
| - // Hide anything that is in the bottom margin of the header row. |
451 |
| - canvas.drawRect(mHeaderColumnWidth, mHeaderTextHeight + mHeaderRowPadding * 2, getWidth(), mHeaderRowPadding * 2 + mHeaderTextHeight + mHeaderMarginBottom + mTimeTextHeight/2, mHeaderColumnBackgroundPaint); |
452 | 450 | }
|
453 | 451 |
|
454 | 452 | private void drawTimeColumnAndAxes(Canvas canvas) {
|
455 | 453 | // Draw the background color for the header column.
|
456 | 454 | canvas.drawRect(0, mHeaderTextHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), mHeaderColumnBackgroundPaint);
|
457 | 455 |
|
| 456 | + // Clip to paint in left column only |
| 457 | + canvas.clipRect(0, mHeaderTextHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), Region.Op.REPLACE); |
| 458 | + |
458 | 459 | for (int i = 0; i < 24; i++) {
|
459 | 460 | float top = mHeaderTextHeight + mHeaderRowPadding * 2 + mCurrentOrigin.y + mHourHeight * i + mHeaderMarginBottom;
|
460 | 461 |
|
@@ -544,6 +545,9 @@ else if (mNewHourHeight > mMaxHourHeight)
|
544 | 545 | }
|
545 | 546 | }
|
546 | 547 |
|
| 548 | + // Clip to paint events only |
| 549 | + canvas.clipRect(mHeaderColumnWidth, mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight/2, getWidth(), getHeight(), Region.Op.REPLACE); |
| 550 | + |
547 | 551 | // Iterate through each day.
|
548 | 552 | Calendar oldFirstVisibleDay = mFirstVisibleDay;
|
549 | 553 | mFirstVisibleDay = (Calendar) today.clone();
|
@@ -629,6 +633,10 @@ else if (day.before(today)) {
|
629 | 633 | startPixel += mWidthPerDay + mColumnGap;
|
630 | 634 | }
|
631 | 635 |
|
| 636 | + |
| 637 | + // Clip to paint header row only |
| 638 | + canvas.clipRect(mHeaderColumnWidth, 0, getWidth(), mHeaderTextHeight + mHeaderRowPadding * 2, Region.Op.REPLACE); |
| 639 | + |
632 | 640 | // Draw the header background.
|
633 | 641 | canvas.drawRect(0, 0, getWidth(), mHeaderTextHeight + mHeaderRowPadding * 2, mHeaderBackgroundPaint);
|
634 | 642 |
|
|
0 commit comments