Skip to content

Commit

Permalink
Merge pull request #3752 from salachi/TIMOB-12134-borderWidth
Browse files Browse the repository at this point in the history
detach the view from the parent before adding to borderView
  • Loading branch information
ayeung committed Jan 28, 2013
2 parents 81996c3 + a854580 commit 7510c78
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,22 @@ private void initializeBorder(KrollDict d, Integer bgColor)
LayoutParams params = new LayoutParams();
params.height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
params.width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
// If the view already has a parent, we need to detach it from the parent
// and add the borderView to the parent as the child
ViewGroup savedParent = null;
android.view.ViewGroup.LayoutParams savedLayoutParams = null;
if (nativeView.getParent() != null) {
ViewParent nativeParent = nativeView.getParent();
if (nativeParent instanceof ViewGroup) {
savedParent = (ViewGroup) nativeParent;
savedLayoutParams = savedParent.getLayoutParams();
savedParent.removeView(nativeView);
}
}
borderView.addView(nativeView, params);
if (savedParent != null) {
savedParent.addView(getOuterView(), savedLayoutParams);
}
borderView.setVisibility(this.visibility);
}

Expand Down

0 comments on commit 7510c78

Please sign in to comment.