Loading core/java/android/view/View.java +25 −0 Original line number Diff line number Diff line Loading @@ -740,6 +740,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private static boolean sUseBrokenMakeMeasureSpec = false; /** * Always return a size of 0 for MeasureSpec values with a mode of UNSPECIFIED */ static boolean sUseZeroUnspecifiedMeasureSpec = false; /** * Ignore any optimizations using the measure cache. */ Loading Loading @@ -3796,6 +3801,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Canvas.sCompatibilityRestore = targetSdkVersion < MNC; // In MNC and newer, our widgets can pass a "hint" value in the size // for UNSPECIFIED MeasureSpecs. This lets child views of scrolling containers // know what the expected parent size is going to be, so e.g. list items can size // themselves at 1/3 the size of their container. It breaks older apps though, // specifically apps that use some popular open source libraries. sUseZeroUnspecifiedMeasureSpec = targetSdkVersion < MNC; sCompatibilityDone = true; } } Loading Loading @@ -21031,6 +21043,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * Like {@link #makeMeasureSpec(int, int)}, but any spec with a mode of UNSPECIFIED * will automatically get a size of 0. Older apps expect this. * * @hide internal use only for compatibility with system widgets and older apps */ public static int makeSafeMeasureSpec(int size, int mode) { if (sUseZeroUnspecifiedMeasureSpec && mode == UNSPECIFIED) { return 0; } return makeMeasureSpec(size, mode); } /** * Extracts the mode from the supplied measure specification. * core/java/android/view/ViewGroup.java +2 −2 Original line number Diff line number Diff line Loading @@ -5963,12 +5963,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else if (childDimension == LayoutParams.MATCH_PARENT) { // Child wants to be our size... find out how big it should // be resultSize = size; resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultMode = MeasureSpec.UNSPECIFIED; } else if (childDimension == LayoutParams.WRAP_CONTENT) { // Child wants to determine its own size.... find out how // big it should be resultSize = size; resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultMode = MeasureSpec.UNSPECIFIED; } break; Loading core/java/android/widget/FastScroller.java +3 −3 Original line number Diff line number Diff line Loading @@ -662,7 +662,7 @@ class FastScroller { final int adjMaxWidth = maxWidth - marginLeft - marginRight; final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); view.measure(widthMeasureSpec, heightMeasureSpec); Loading Loading @@ -702,7 +702,7 @@ class FastScroller { final int containerWidth = container.width(); final int adjMaxWidth = containerWidth - marginLeft - marginRight; final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); preview.measure(widthMeasureSpec, heightMeasureSpec); Loading Loading @@ -768,7 +768,7 @@ class FastScroller { final Rect container = mContainerRect; final int maxWidth = container.width(); final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); track.measure(widthMeasureSpec, heightMeasureSpec); Loading core/java/android/widget/GridView.java +1 −1 Original line number Diff line number Diff line Loading @@ -1073,7 +1073,7 @@ public class GridView extends AbsListView { p.forceAdd = true; int childHeightSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.makeSafeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED), 0, p.height); int childWidthSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(mColumnWidth, MeasureSpec.EXACTLY), 0, p.width); Loading core/java/android/widget/LinearLayout.java +2 −2 Original line number Diff line number Diff line Loading @@ -1062,9 +1062,9 @@ public class LinearLayout extends ViewGroup { // use as much space as it wants because we can shrink things // later (and re-measure). if (baselineAligned) { final int freeWidthSpec = MeasureSpec.makeMeasureSpec( final int freeWidthSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.UNSPECIFIED); final int freeHeightSpec = MeasureSpec.makeMeasureSpec( final int freeHeightSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED); child.measure(freeWidthSpec, freeHeightSpec); } else { Loading Loading
core/java/android/view/View.java +25 −0 Original line number Diff line number Diff line Loading @@ -740,6 +740,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private static boolean sUseBrokenMakeMeasureSpec = false; /** * Always return a size of 0 for MeasureSpec values with a mode of UNSPECIFIED */ static boolean sUseZeroUnspecifiedMeasureSpec = false; /** * Ignore any optimizations using the measure cache. */ Loading Loading @@ -3796,6 +3801,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Canvas.sCompatibilityRestore = targetSdkVersion < MNC; // In MNC and newer, our widgets can pass a "hint" value in the size // for UNSPECIFIED MeasureSpecs. This lets child views of scrolling containers // know what the expected parent size is going to be, so e.g. list items can size // themselves at 1/3 the size of their container. It breaks older apps though, // specifically apps that use some popular open source libraries. sUseZeroUnspecifiedMeasureSpec = targetSdkVersion < MNC; sCompatibilityDone = true; } } Loading Loading @@ -21031,6 +21043,19 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } /** * Like {@link #makeMeasureSpec(int, int)}, but any spec with a mode of UNSPECIFIED * will automatically get a size of 0. Older apps expect this. * * @hide internal use only for compatibility with system widgets and older apps */ public static int makeSafeMeasureSpec(int size, int mode) { if (sUseZeroUnspecifiedMeasureSpec && mode == UNSPECIFIED) { return 0; } return makeMeasureSpec(size, mode); } /** * Extracts the mode from the supplied measure specification. *
core/java/android/view/ViewGroup.java +2 −2 Original line number Diff line number Diff line Loading @@ -5963,12 +5963,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else if (childDimension == LayoutParams.MATCH_PARENT) { // Child wants to be our size... find out how big it should // be resultSize = size; resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultMode = MeasureSpec.UNSPECIFIED; } else if (childDimension == LayoutParams.WRAP_CONTENT) { // Child wants to determine its own size.... find out how // big it should be resultSize = size; resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultMode = MeasureSpec.UNSPECIFIED; } break; Loading
core/java/android/widget/FastScroller.java +3 −3 Original line number Diff line number Diff line Loading @@ -662,7 +662,7 @@ class FastScroller { final int adjMaxWidth = maxWidth - marginLeft - marginRight; final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); view.measure(widthMeasureSpec, heightMeasureSpec); Loading Loading @@ -702,7 +702,7 @@ class FastScroller { final int containerWidth = container.width(); final int adjMaxWidth = containerWidth - marginLeft - marginRight; final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(adjMaxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); preview.measure(widthMeasureSpec, heightMeasureSpec); Loading Loading @@ -768,7 +768,7 @@ class FastScroller { final Rect container = mContainerRect; final int maxWidth = container.width(); final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST); final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(container.height(), final int heightMeasureSpec = MeasureSpec.makeSafeMeasureSpec(container.height(), MeasureSpec.UNSPECIFIED); track.measure(widthMeasureSpec, heightMeasureSpec); Loading
core/java/android/widget/GridView.java +1 −1 Original line number Diff line number Diff line Loading @@ -1073,7 +1073,7 @@ public class GridView extends AbsListView { p.forceAdd = true; int childHeightSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.makeSafeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED), 0, p.height); int childWidthSpec = getChildMeasureSpec( MeasureSpec.makeMeasureSpec(mColumnWidth, MeasureSpec.EXACTLY), 0, p.width); Loading
core/java/android/widget/LinearLayout.java +2 −2 Original line number Diff line number Diff line Loading @@ -1062,9 +1062,9 @@ public class LinearLayout extends ViewGroup { // use as much space as it wants because we can shrink things // later (and re-measure). if (baselineAligned) { final int freeWidthSpec = MeasureSpec.makeMeasureSpec( final int freeWidthSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.UNSPECIFIED); final int freeHeightSpec = MeasureSpec.makeMeasureSpec( final int freeHeightSpec = MeasureSpec.makeSafeMeasureSpec( MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.UNSPECIFIED); child.measure(freeWidthSpec, freeHeightSpec); } else { Loading