Skip to content

Commit d91c2ac

Browse files
committed
Issue #42: Update calculating the padding of line number to solve overlap problem
1 parent e002f3d commit d91c2ac

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codeview/src/main/java/com/amrdeveloper/codeview/CodeView.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ protected void onDraw(Canvas canvas) {
186186
}
187187
}
188188

189-
// Calculate padding depending on current line number
190-
final int paddingLeft = 50 + (int) Math.log10(lineCount) * 10;
189+
// Calculate padding depending on number of lines and the size of line number text
190+
final int lineNumberDigitCount = (int) (Math.log10(lineCount) + 1);
191+
final int paddingLeft = (int) (lineNumberPaint.getTextSize() * lineNumberDigitCount);
191192
setPadding(paddingLeft, getPaddingTop(), getPaddingRight(), getPaddingBottom());
192193
}
193194
}
@@ -638,7 +639,7 @@ public void setLineNumberTextColor(int color) {
638639

639640
/**
640641
* Modify the line number text size
641-
* @param size The new size value
642+
* @param size The new text size in pixel units
642643
* @since 1.1.0
643644
*/
644645
public void setLineNumberTextSize(float size) {

0 commit comments

Comments
 (0)