Skip to content

Commit 8b48244

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Centered text is not updated"
2 parents b67c63b + fb9f5be commit 8b48244

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
@@ -1226,7 +1226,6 @@ void onDraw(Canvas canvas, Layout layout, Path highlight, Paint highlightPaint,
12261226
private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highlight,
12271227
Paint highlightPaint, int cursorOffsetVertical) {
12281228
final int width = mTextView.getWidth();
1229-
final int height = mTextView.getHeight();
12301229

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

1248+
final int scrollX = mTextView.getScrollX();
1249+
final int scrollY = mTextView.getScrollY();
1250+
canvas.translate(scrollX, scrollY);
1251+
12491252
int endOfPreviousBlock = -1;
12501253
int searchStartIndex = 0;
12511254
for (int i = 0; i < numberOfBlocks; i++) {
@@ -1281,9 +1284,9 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
12811284
hardwareCanvas.onPreDraw(null);
12821285
// drawText is always relative to TextView's origin, this translation brings
12831286
// this range of text back to the top of the viewport
1284-
hardwareCanvas.translate(0, -top);
1287+
hardwareCanvas.translate(-scrollX, -top);
12851288
layout.drawText(hardwareCanvas, blockBeginLine, blockEndLine);
1286-
hardwareCanvas.translate(0, top);
1289+
hardwareCanvas.translate(scrollX, top);
12871290
} finally {
12881291
hardwareCanvas.onPostDraw();
12891292
blockDisplayList.end();
@@ -1299,6 +1302,8 @@ private void drawHardwareAccelerated(Canvas canvas, Layout layout, Path highligh
12991302
((HardwareCanvas) canvas).drawDisplayList(blockDisplayList, null,
13001303
0 /* no child clipping, our TextView parent enforces it */);
13011304
endOfPreviousBlock = blockEndLine;
1305+
1306+
canvas.translate(-scrollX, -scrollY);
13021307
}
13031308
} else {
13041309
// Boring layout is used for empty and hint text

0 commit comments

Comments
 (0)