File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
library/src/main/java/com/alamkanak/weekview Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -400,11 +400,17 @@ public boolean onScale(ScaleGestureDetector detector) {
400
400
}
401
401
402
402
/**
403
- * Initialize time column width. Calculate value with latest possible hour (supposed widest text)
403
+ * Initialize time column width. Calculate value with all possible hours (supposed widest text)
404
404
*/
405
405
private void initTextTimeWidth () {
406
- String timeSample = getDateTimeInterpreter ().interpretTime (23 );
407
- mTimeTextWidth = mTimeTextPaint .measureText (timeSample );
406
+ mTimeTextWidth = 0 ;
407
+ for (int i = 0 ; i < 24 ; i ++) {
408
+ // measure time string and get max width
409
+ String time = getDateTimeInterpreter ().interpretTime (i );
410
+ if (time == null )
411
+ throw new IllegalStateException ("A DateTimeInterpreter must not return null time" );
412
+ mTimeTextWidth = Math .max (mTimeTextWidth , mTimeTextPaint .measureText (time ));
413
+ }
408
414
}
409
415
410
416
@ Override
You can’t perform that action at this time.
0 commit comments