summaryrefslogtreecommitdiff
path: root/core/java/android/view/ViewGroup.java
diff options
context:
space:
mode:
authorPhilip Milne <pmilne@google.com>2012-04-24 22:12:36 -0700
committerPhilip Milne <pmilne@google.com>2012-04-27 16:46:57 -0700
commit7a23b49a8ceb07d3fa12c45fd42cd16131fd746a (patch)
tree3d0ba87bbc84830260a01a34d0abb5c13d6dd4d3 /core/java/android/view/ViewGroup.java
parentc887843b19c5a31bcd14e0b29b035d2a6e1e6149 (diff)
Fixes for optical bounds feature.
1. Make the feature opt-in (ViewGroup::layoutMode defaults to CLIP_BOUNDS) without inheritance. 2. Rename COMPONENT_BOUNDS to CLIP_BOUNDS. 3. Rename LAYOUT_BOUNDS to OPTICAL_BOUNDS. 4. Complete GridLayout implementation. 5. Change the default_gap between components to 8dp, to align with the Style Guide. Change-Id: I8d40dfc5f4ca469f6424eb3ff60d07bec56e3a9f
Diffstat (limited to 'core/java/android/view/ViewGroup.java')
-rw-r--r--core/java/android/view/ViewGroup.java45
1 files changed, 15 insertions, 30 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 9009e9ae9f2e..625062317599 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -173,10 +173,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
protected int mGroupFlags;
/*
- * THe layout mode: either {@link #UNDEFINED_LAYOUT_MODE}, {@link #COMPONENT_BOUNDS} or
- * {@link #LAYOUT_BOUNDS}
+ * The layout mode: either {@link #CLIP_BOUNDS} or {@link #OPTICAL_BOUNDS}
*/
- private int mLayoutMode = UNDEFINED_LAYOUT_MODE;
+ private int mLayoutMode = CLIP_BOUNDS;
/**
* NOTE: If you change the flags below make sure to reflect the changes
@@ -345,19 +344,20 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
// Layout Modes
- private static final int UNDEFINED_LAYOUT_MODE = -1;
-
/**
* This constant is a {@link #setLayoutMode(int) layoutMode}.
- * Component bounds are the raw values of {@link #getLeft() left}, {@link #getTop() top},
+ * Clip bounds are the raw values of {@link #getLeft() left}, {@link #getTop() top},
* {@link #getRight() right} and {@link #getBottom() bottom}.
*/
- public static final int COMPONENT_BOUNDS = 0;
+ public static final int CLIP_BOUNDS = 0;
/**
* This constant is a {@link #setLayoutMode(int) layoutMode}.
+ * Optical bounds describe where a widget appears to be. They sit inside the clip
+ * bounds which need to cover a larger area to allow other effects,
+ * such as shadows and glows, to be drawn.
*/
- public static final int LAYOUT_BOUNDS = 1;
+ public static final int OPTICAL_BOUNDS = 1;
/**
* We clip to padding when FLAG_CLIP_TO_PADDING and FLAG_PADDING_NOT_NULL
@@ -2696,10 +2696,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*/
protected void onDebugDraw(Canvas canvas) {
// Draw optical bounds
- if (getLayoutMode() == LAYOUT_BOUNDS) {
+ if (getLayoutMode() == OPTICAL_BOUNDS) {
for (int i = 0; i < getChildCount(); i++) {
View c = getChildAt(i);
- Insets insets = c.getLayoutInsets();
+ Insets insets = c.getOpticalInsets();
drawRect(canvas,
c.getLeft() + insets.left,
c.getTop() + insets.top,
@@ -4597,37 +4597,22 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
}
/**
- * Returns the basis of alignment during the layout of this view group:
- * either {@link #COMPONENT_BOUNDS} or {@link #LAYOUT_BOUNDS}.
+ * Returns the basis of alignment during layout operations on this view group:
+ * either {@link #CLIP_BOUNDS} or {@link #OPTICAL_BOUNDS}.
*
* @return the layout mode to use during layout operations
*
* @see #setLayoutMode(int)
*/
public int getLayoutMode() {
- if (mLayoutMode == UNDEFINED_LAYOUT_MODE) {
- ViewParent parent = getParent();
- if (parent instanceof ViewGroup) {
- ViewGroup viewGroup = (ViewGroup) parent;
- return viewGroup.getLayoutMode();
- } else {
- int targetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
- boolean preJellyBean = targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN;
- return preJellyBean ? COMPONENT_BOUNDS : LAYOUT_BOUNDS;
- }
-
- }
return mLayoutMode;
}
/**
- * Sets the basis of alignment during alignment of this view group.
- * Valid values are either {@link #COMPONENT_BOUNDS} or {@link #LAYOUT_BOUNDS}.
+ * Sets the basis of alignment during the layout of this view group.
+ * Valid values are either {@link #CLIP_BOUNDS} or {@link #OPTICAL_BOUNDS}.
* <p>
- * The default is to query the property of the parent if this view group has a parent.
- * If this ViewGroup is the root of the view hierarchy the default
- * value is {@link #LAYOUT_BOUNDS} for target SDK's greater than JellyBean,
- * {@link #LAYOUT_BOUNDS} otherwise.
+ * The default is {@link #CLIP_BOUNDS}.
*
* @param layoutMode the layout mode to use during layout operations
*