Skip to content

Commit fb9f5be

Browse files
author
Gilles Debunne
committed
Centered text is not updated
Bug 6378843 Emergency fix. May submit a proper fix with less translations later. Change-Id: I9d8348e29d5436580202d3ee0456d341bf81dab8
1 parent ad6283e commit fb9f5be

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

core/java/android/widget/Editor.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,6 @@ void onDraw(Canvas canvas, Layout layout, Path highlight, Paint highlightPaint,
12251225
private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highlight,
12261226
Paint highlightPaint, int cursorOffsetVertical) {
12271227
final int width = mTextView.getWidth();
1228-
final int height = mTextView.getHeight();
12291228

12301229
final long lineRange = layout.getLineRangeForDraw(canvas);
12311230
int firstLine = TextUtils.unpackRangeStartFromLong(lineRange);
@@ -1245,6 +1244,10 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
12451244
int[] blockIndices = dynamicLayout.getBlockIndices();
12461245
final int numberOfBlocks = dynamicLayout.getNumberOfBlocks();
12471246

1247+
final int scrollX = mTextView.getScrollX();
1248+
final int scrollY = mTextView.getScrollY();
1249+
canvas.translate(scrollX, scrollY);
1250+
12481251
int endOfPreviousBlock = -1;
12491252
int searchStartIndex = 0;
12501253
for (int i = 0; i < numberOfBlocks; i++) {
@@ -1280,9 +1283,9 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
12801283
hardwareCanvas.onPreDraw(null);
12811284
// drawText is always relative to TextView's origin, this translation brings
12821285
// this range of text back to the top of the viewport
1283-
hardwareCanvas.translate(0, -top);
1286+
hardwareCanvas.translate(-scrollX, -top);
12841287
layout.drawText(hardwareCanvas, blockBeginLine, blockEndLine);
1285-
hardwareCanvas.translate(0, top);
1288+
hardwareCanvas.translate(scrollX, top);
12861289
} finally {
12871290
hardwareCanvas.onPostDraw();
12881291
blockDisplayList.end();
@@ -1298,6 +1301,8 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
12981301
((HardwareCanvas) canvas).drawDisplayList(blockDisplayList, null,
12991302
0 /* no child clipping, our TextView parent enforces it */);
13001303
endOfPreviousBlock = blockEndLine;
1304+
1305+
canvas.translate(-scrollX, -scrollY);
13011306
}
13021307
} else {
13031308
// Boring layout is used for empty and hint text

0 commit comments

Comments
 (0)