【发布时间】:2014-10-29 00:20:24
【问题描述】:
在以编程方式在 LinearLayout 对象中添加两个 FrameLayout 对象时,在将第二个 FrameLayout 对象添加到 LinearLayout 对象时出现以下异常。谁能帮忙。
Java.Lang.IllegalStateException:指定的孩子已经有一个父母。您必须先在孩子的父母上调用 removeView()。
这里是代码
ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent);
MainView = new LinearLayout(_context);
MainView.LayoutParameters = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.MatchParent);
MainView.Orientation = Orientation.Vertical;
MainView.SetVerticalGravity(GravityFlags.Center);
MainView.SetHorizontalGravity(GravityFlags.Center);
_currentSwipableItemReflectionFrameLayout = _currentSwipableItemFrameLayout;
_currentSwipableItemReflectionFrameLayout.RotationX = 180;
_currentSwipableItemReflectionFrameLayout.Alpha = 0.3f;
MainView.AddView(_currentSwipableItemFrameLayout,param);
MainView.AddView(_currentSwipableItemReflectionFrameLayout,param);
AddView(MainView);
【问题讨论】:
标签: android-layout xamarin.android