From b15703c9b4bd77383344a06c0043f5f7448b24ae Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Mon, 5 Jan 2015 14:20:42 -0800 Subject: [PATCH] Avoid double-translating View background Reverse-translate the canvas before passing to Drawable.draw() so that we don't double-apply the drawable's translation. BUG: 18904688 Change-Id: I8450de9b240ddeae887b4e1003c0608da814a001 --- core/java/android/view/View.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 27c1978743016..23792be63652b 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15531,6 +15531,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int width = bounds.width(); final int height = bounds.height(); final HardwareCanvas canvas = renderNode.start(width, height); + + // Reverse left/top translation done by drawable canvas, which will + // instead be applied by rendernode's LTRB bounds below. This way, the + // drawable's bounds match with its rendernode bounds and its content + // will lie within those bounds in the rendernode tree. + canvas.translate(-bounds.left, -bounds.top); + try { drawable.draw(canvas); } finally {