diff --git a/src/api-impl/android/view/ViewGroup.java b/src/api-impl/android/view/ViewGroup.java index a97b0109..63882f61 100644 --- a/src/api-impl/android/view/ViewGroup.java +++ b/src/api-impl/android/view/ViewGroup.java @@ -41,11 +41,15 @@ public class ViewGroup extends View implements ViewParent, ViewManager { } public void addView(View child) { - addView(child, -1, null); + addView(child, -1); } public void addView(View child, int index) { - addView(child, index, null); + LayoutParams params = child.getLayoutParams(); + if (params == null) { + params = generateDefaultLayoutParams(); + } + addView(child, index, params); } public void addView(View child, LayoutParams params) { @@ -53,20 +57,25 @@ public class ViewGroup extends View implements ViewParent, ViewManager { } public void addView(View child, int width, int height) { - addView(child, new LayoutParams(width, height)); + final LayoutParams params = generateDefaultLayoutParams(); + params.width = width; + params.height = height; + addView(child, params); } private void addViewInternal(View child, int index, LayoutParams params) { if (child.parent == this) return; - if (params != null) { - child.setLayoutParams(params); + if (!checkLayoutParams(params)) { + params = generateLayoutParams(params); } + child.setLayoutParams(params); child.parent = this; if (index < 0) index = children.size(); children.add(index, child); native_addView(widget, child.widget, index, params); + requestLayout(); } public void addView(View child, int index, LayoutParams params) { @@ -312,6 +321,12 @@ public class ViewGroup extends View implements ViewParent, ViewManager { super(); } + public MarginLayoutParams(LayoutParams params) { + super(); + width = params.width; + height = params.height; + } + public MarginLayoutParams(int width, int height) { super(width, height); } diff --git a/src/api-impl/android/widget/FrameLayout.java b/src/api-impl/android/widget/FrameLayout.java index 40fa868e..e77135c6 100644 --- a/src/api-impl/android/widget/FrameLayout.java +++ b/src/api-impl/android/widget/FrameLayout.java @@ -27,10 +27,6 @@ public class FrameLayout extends ViewGroup { @Override protected native void native_removeView(long widget, long child); - public void addView(View child, int index) { - addView(child, index, null); - } - @Override public LayoutParams generateLayoutParams(AttributeSet attrs) { return new LayoutParams(getContext(), attrs);