@@ -820,29 +820,29 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
820820 invalidate()
821821 }
822822
823- var weekDaysHeaderRowPadding: Int = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 6f , resources.displayMetrics).toInt()
823+ var weekDaysHeaderRowPadding = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 6f , resources.displayMetrics).toInt()
824824 set(value) {
825825 field = value
826826 invalidate()
827827 }
828828
829- var spaceBetweenWeekDaysAndAllDayEvents: Int = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 0f , resources.displayMetrics).toInt()
829+ var spaceBetweenWeekDaysAndAllDayEvents = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 3f , resources.displayMetrics).toInt()
830830 set(value) {
831831 if (field == value)
832832 return
833833 field = value
834834 invalidate()
835835 }
836836
837- var spaceBelowAllDayEvents: Int = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 3f , resources.displayMetrics).toInt()
837+ var spaceBelowAllDayEvents = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 3f , resources.displayMetrics).toInt()
838838 set(value) {
839839 if (field == value)
840840 return
841841 field = value
842842 invalidate()
843843 }
844844
845- var spaceBetweenHeaderWeekDayTitleAndSubtitle: Int = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 6f , context.resources.displayMetrics).toInt()
845+ var spaceBetweenHeaderWeekDayTitleAndSubtitle = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 6f , context.resources.displayMetrics).toInt()
846846 set(value) {
847847 if (field == value)
848848 return
@@ -1101,20 +1101,21 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
11011101 sideTitleTextPaint.typeface = typeface
11021102
11031103 // Measure settings for header row.
1104+ // TODO measure the text that will actually be used, based on the locale and dates. Important because various characters might look different.
1105+ val sampleText = " ABCDEFGHIKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz0123456789"
11041106 mHeaderWeekDayTitleTextPaint.color = headerColumnTextColor
11051107 mHeaderWeekDayTitleTextPaint.textSize = headerWeekDayTitleTextSize
11061108 mHeaderWeekDayTitleTextPaint.typeface = typeface
1107- mHeaderWeekDayTitleTextPaint.getTextBounds(" ABCDEFGHIKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz0123456789 " , 0 , exampleTime .length, rect)
1109+ mHeaderWeekDayTitleTextPaint.getTextBounds(sampleText , 0 , sampleText .length, rect)
11081110 mHeaderWeekDayTitleTextHeight = rect.height().toFloat()
11091111
11101112 // measure settings for header subtitle
11111113 mHeaderWeekDaySubtitleTextPaint.color = headerColumnTextColor
11121114 mHeaderWeekDaySubtitleTextPaint.textSize = headerWeekDaySubtitleTextSize
11131115 mHeaderWeekDaySubtitleTextPaint.typeface = typeface
1114- mHeaderWeekDaySubtitleTextPaint.getTextBounds(" ABCDEFGHIKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz0123456789 " , 0 , exampleTime .length, rect)
1116+ mHeaderWeekDaySubtitleTextPaint.getTextBounds(sampleText , 0 , sampleText .length, rect)
11151117 mHeaderWeekDaySubtitleTextHeight = rect.height().toFloat()
11161118
1117-
11181119 // Prepare header background paint.
11191120 mHeaderBackgroundPaint.color = headerRowBackgroundColor
11201121
@@ -1475,10 +1476,10 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
14751476 canvas.clipRect(0f , 0f , mTimeTextWidth + headerColumnPadding * 2 , mHeaderHeight + weekDaysHeaderRowPadding * 2 )
14761477 val headerTitleAndSubtitleTextHeight = mHeaderWeekDayTitleTextHeight + (if (isSubtitleHeaderEnabled) mHeaderWeekDaySubtitleTextHeight + spaceBetweenHeaderWeekDayTitleAndSubtitle else 0.0f )
14771478 if (enableDrawHeaderBackgroundOnlyOnWeekDays)
1478- canvas.drawRect(0f , 0f , mTimeTextWidth + headerColumnPadding * 2 , headerTitleAndSubtitleTextHeight
1479- + weekDaysHeaderRowPadding * 2 , mHeaderBackgroundPaint)
1479+ canvas.drawRect(0f , 0f , mTimeTextWidth + headerColumnPadding * 2 , headerTitleAndSubtitleTextHeight + weekDaysHeaderRowPadding * 2 , mHeaderBackgroundPaint)
14801480 else
1481- canvas.drawRect(0f , 0f , mTimeTextWidth + headerColumnPadding * 2 , mHeaderHeight + weekDaysHeaderRowPadding * 2 , mHeaderBackgroundPaint)
1481+ canvas.drawRect(canvas.clipBounds, mHeaderBackgroundPaint)
1482+ // canvas.drawRect(0f, 0f, mTimeTextWidth + headerColumnPadding * 2, mHeaderHeight + weekDaysHeaderRowPadding * 2, mHeaderBackgroundPaint)
14821483
14831484 // draw text on the left of the week days
14841485 if (! TextUtils .isEmpty(sideTitleText))
@@ -1521,7 +1522,7 @@ class WeekView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
15211522 // draw day subtitle
15221523 if (isSubtitleHeaderEnabled) {
15231524 val subtitleText = weekDaySubtitleInterpreter!! .interpretDate(day)
1524- canvas.drawText(subtitleText, startPixel + mWidthPerDay / 2 , headerTitleAndSubtitleTextHeight + weekDaysHeaderRowPadding + spaceBetweenHeaderWeekDayTitleAndSubtitle ,
1525+ canvas.drawText(subtitleText, startPixel + mWidthPerDay / 2 , headerTitleAndSubtitleTextHeight + weekDaysHeaderRowPadding,
15251526 if (isToday) mHeaderWeekDaySubtitleTodayTextPaint else mHeaderWeekDaySubtitleTextPaint)
15261527 }
15271528 drawAllDayEvents(day, startPixel, canvas)
0 commit comments