diff options
author | Philip Milne <pmilne@google.com> | 2012-04-24 19:42:25 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-24 19:42:25 -0700 |
commit | 8f94ec1565339015f3c62b3936b99a16f094c5aa (patch) | |
tree | a19713623b17cdc3c4a483f43de1d51caf9ffb29 /core/java/android | |
parent | 1686ad93710addf8ca490df340b6cb869a8568f6 (diff) | |
parent | 604f440dfd6e5ee857f1e71d12c635d4ee1afcbc (diff) | |
download | frameworks_base-8f94ec1565339015f3c62b3936b99a16f094c5aa.zip frameworks_base-8f94ec1565339015f3c62b3936b99a16f094c5aa.tar.gz frameworks_base-8f94ec1565339015f3c62b3936b99a16f094c5aa.tar.bz2 |
Merge "Fix for layout debug mode."
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/view/ViewGroup.java | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 343ae4c..9009e9a 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -382,6 +382,16 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager private static final int ARRAY_INITIAL_CAPACITY = 12; private static final int ARRAY_CAPACITY_INCREMENT = 12; + private static Paint DEBUG_PAINT; + + private static Paint getDebugPaint() { + if (DEBUG_PAINT == null) { + DEBUG_PAINT = new Paint(); + DEBUG_PAINT.setStyle(Paint.Style.STROKE); + } + return DEBUG_PAINT; + } + // Used to draw cached views Paint mCachePaint; @@ -2665,7 +2675,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager return b; } - private static void drawRect(Canvas canvas, int x1, int y1, int x2, int y2, Paint paint) { + private static void drawRect(Canvas canvas, int x1, int y1, int x2, int y2, int color) { + Paint paint = getDebugPaint(); + paint.setColor(color); canvas.drawRect(x1, y1, x2 - 1, y2 - 1, paint); } @@ -2675,7 +2687,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager protected void onDebugDrawMargins(Canvas canvas) { for (int i = 0; i < getChildCount(); i++) { View c = getChildAt(i); - c.getLayoutParams().onDebugDraw(this, canvas); + c.getLayoutParams().onDebugDraw(c, canvas); } } @@ -2683,12 +2695,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * @hide */ protected void onDebugDraw(Canvas canvas) { - Paint paint = new Paint(); - paint.setStyle(Paint.Style.STROKE); - // Draw optical bounds if (getLayoutMode() == LAYOUT_BOUNDS) { - paint.setColor(Color.RED); for (int i = 0; i < getChildCount(); i++) { View c = getChildAt(i); Insets insets = c.getLayoutInsets(); @@ -2696,19 +2704,18 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager c.getLeft() + insets.left, c.getTop() + insets.top, c.getRight() - insets.right, - c.getBottom() - insets.bottom, paint); + c.getBottom() - insets.bottom, Color.RED); } } + // Draw margins + onDebugDrawMargins(canvas); + // Draw bounds - paint.setColor(Color.BLUE); for (int i = 0; i < getChildCount(); i++) { View c = getChildAt(i); - drawRect(canvas, c.getLeft(), c.getTop(), c.getRight(), c.getBottom(), paint); + drawRect(canvas, c.getLeft(), c.getTop(), c.getRight(), c.getBottom(), Color.BLUE); } - - // Draw margins - onDebugDrawMargins(canvas); } /** @@ -5800,15 +5807,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager */ @Override public void onDebugDraw(View view, Canvas canvas) { - Paint paint = new Paint(); - paint.setStyle(Paint.Style.STROKE); - paint.setColor(Color.MAGENTA); - drawRect(canvas, view.getLeft() - leftMargin, view.getTop() - topMargin, view.getRight() + rightMargin, - view.getBottom() + bottomMargin, paint); + view.getBottom() + bottomMargin, Color.MAGENTA); } } |