Skip to content

Commit 0fd888f

Browse files
committed
1,修复设置四个方向的图片,删除线和下划线错位问题
1 parent 17cd3e8 commit 0fd888f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

FormatTextView/src/main/java/com/flyjingfish/formattextview/FormatTextView.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,11 @@ class FormatTextView : BaseTextView {
443443
val bound = Rect()
444444
val line = layout.getLineForOffset(index)
445445
val baseline = layout.getLineBaseline(line)
446-
bound.bottom = baseline
447-
bound.left = layout.getPrimaryHorizontal(index).toInt()
448-
bound.right = layout.getPrimaryHorizontal(index + 1).toInt()
446+
bound.bottom = baseline+compoundPaddingTop
447+
bound.left = layout.getPrimaryHorizontal(index).toInt()+compoundPaddingLeft
448+
bound.right = layout.getPrimaryHorizontal(index + 1).toInt()+compoundPaddingLeft
449449
if (bound.right < bound.left) {
450-
bound.right = layout.getLineRight(line).toInt()
450+
bound.right = layout.getLineRight(line).toInt()+compoundPaddingLeft
451451
}
452452
return bound;
453453
}
@@ -456,11 +456,11 @@ class FormatTextView : BaseTextView {
456456
val layout = layout
457457
val bound = Rect()
458458
val line = layout.getLineForOffset(index)
459-
bound.bottom = layout.getLineBaseline(line)
460-
bound.left = layout.getPrimaryHorizontal(index).toInt()
461-
bound.right = layout.getPrimaryHorizontal(index + 1).toInt()
459+
bound.bottom = layout.getLineBaseline(line)+compoundPaddingTop
460+
bound.left = layout.getPrimaryHorizontal(index).toInt()+compoundPaddingLeft
461+
bound.right = layout.getPrimaryHorizontal(index + 1).toInt()+compoundPaddingLeft
462462
if (bound.right < bound.left) {
463-
bound.right = layout.getLineRight(line).toInt()
463+
bound.right = layout.getLineRight(line).toInt()+compoundPaddingLeft
464464
}
465465
return bound;
466466
}

0 commit comments

Comments
 (0)