Loading core/java/android/view/LayoutInflater.java +12 −16 Original line number Original line Diff line number Diff line Loading @@ -946,26 +946,22 @@ public abstract class LayoutInflater { attrs, R.styleable.Include); attrs, R.styleable.Include); final int id = a.getResourceId(R.styleable.Include_id, View.NO_ID); final int id = a.getResourceId(R.styleable.Include_id, View.NO_ID); final int visibility = a.getInt(R.styleable.Include_visibility, -1); final int visibility = a.getInt(R.styleable.Include_visibility, -1); final boolean hasWidth = a.hasValue(R.styleable.Include_layout_width); final boolean hasHeight = a.hasValue(R.styleable.Include_layout_height); a.recycle(); a.recycle(); // We try to load the layout params set in the <include /> tag. If // We try to load the layout params set in the <include /> tag. // they don't exist, we will rely on the layout params set in the // If the parent can't generate layout params (ex. missing width // included XML file. // or height for the framework ViewGroups, though this is not // During a layoutparams generation, a runtime exception is thrown // necessarily true of all ViewGroups) then we expect it to throw // if either layout_width or layout_height is missing. We catch // a runtime exception. // this exception and set localParams accordingly: true means we // We catch this exception and set localParams accordingly: true // successfully loaded layout params from the <include /> tag, // means we successfully loaded layout params from the <include> // false means we need to rely on the included layout params. // tag, false means we need to rely on the included layout params. ViewGroup.LayoutParams params = null; ViewGroup.LayoutParams params = null; if (hasWidth && hasHeight) { try { try { params = group.generateLayoutParams(attrs); params = group.generateLayoutParams(attrs); } catch (RuntimeException e) { } catch (RuntimeException e) { // Ignore, just fail over to child attrs. // Ignore, just fail over to child attrs. } } } if (params == null) { if (params == null) { params = group.generateLayoutParams(childAttrs); params = group.generateLayoutParams(childAttrs); } } Loading core/res/res/values/attrs.xml +2 −3 Original line number Original line Diff line number Diff line Loading @@ -2725,12 +2725,11 @@ <attr name="value" /> <attr name="value" /> </declare-styleable> </declare-styleable> <!-- Attributes that can be assigned to an <include> tag. --> <!-- Attributes that can be assigned to an <include> tag. @hide --> <declare-styleable name="Include"> <declare-styleable name="Include"> <attr name="id" /> <attr name="id" /> <attr name="visibility" /> <attr name="visibility" /> <attr name="layout_width" /> <attr name="layout_height" /> </declare-styleable> </declare-styleable> <!-- Attributes that can be used with a {@link android.view.ViewGroup} or any <!-- Attributes that can be used with a {@link android.view.ViewGroup} or any Loading Loading
core/java/android/view/LayoutInflater.java +12 −16 Original line number Original line Diff line number Diff line Loading @@ -946,26 +946,22 @@ public abstract class LayoutInflater { attrs, R.styleable.Include); attrs, R.styleable.Include); final int id = a.getResourceId(R.styleable.Include_id, View.NO_ID); final int id = a.getResourceId(R.styleable.Include_id, View.NO_ID); final int visibility = a.getInt(R.styleable.Include_visibility, -1); final int visibility = a.getInt(R.styleable.Include_visibility, -1); final boolean hasWidth = a.hasValue(R.styleable.Include_layout_width); final boolean hasHeight = a.hasValue(R.styleable.Include_layout_height); a.recycle(); a.recycle(); // We try to load the layout params set in the <include /> tag. If // We try to load the layout params set in the <include /> tag. // they don't exist, we will rely on the layout params set in the // If the parent can't generate layout params (ex. missing width // included XML file. // or height for the framework ViewGroups, though this is not // During a layoutparams generation, a runtime exception is thrown // necessarily true of all ViewGroups) then we expect it to throw // if either layout_width or layout_height is missing. We catch // a runtime exception. // this exception and set localParams accordingly: true means we // We catch this exception and set localParams accordingly: true // successfully loaded layout params from the <include /> tag, // means we successfully loaded layout params from the <include> // false means we need to rely on the included layout params. // tag, false means we need to rely on the included layout params. ViewGroup.LayoutParams params = null; ViewGroup.LayoutParams params = null; if (hasWidth && hasHeight) { try { try { params = group.generateLayoutParams(attrs); params = group.generateLayoutParams(attrs); } catch (RuntimeException e) { } catch (RuntimeException e) { // Ignore, just fail over to child attrs. // Ignore, just fail over to child attrs. } } } if (params == null) { if (params == null) { params = group.generateLayoutParams(childAttrs); params = group.generateLayoutParams(childAttrs); } } Loading
core/res/res/values/attrs.xml +2 −3 Original line number Original line Diff line number Diff line Loading @@ -2725,12 +2725,11 @@ <attr name="value" /> <attr name="value" /> </declare-styleable> </declare-styleable> <!-- Attributes that can be assigned to an <include> tag. --> <!-- Attributes that can be assigned to an <include> tag. @hide --> <declare-styleable name="Include"> <declare-styleable name="Include"> <attr name="id" /> <attr name="id" /> <attr name="visibility" /> <attr name="visibility" /> <attr name="layout_width" /> <attr name="layout_height" /> </declare-styleable> </declare-styleable> <!-- Attributes that can be used with a {@link android.view.ViewGroup} or any <!-- Attributes that can be used with a {@link android.view.ViewGroup} or any Loading