You must call removeView () on the child's parent first 처리
1988 단어 BugFix
if (child.getParent() instanceof ViewGroup) {
ViewGroup parent = (ViewGroup) child.getParent();
LayoutTransition layoutTransition = null;
if (parent.getLayoutTransition() != null) {
layoutTransition = parent.getLayoutTransition();
parent.setLayoutTransition(null);
}
parent.removeView(child);
if (layoutTransition != null) {
parent.setLayoutTransition(layoutTransition);
}
if (child.getParent() != null) {
// LayoutTransition removeView ,
ViewGroupUtils.cancelLayoutTransition(parent);
// view view
if (child.getParent() != null && FIELD_VIEW_PARENT != null) {
// parent
ReflectionUtils.setFieldValue(child, ReflectionUtils.getPrivateField(View.class, "mParent"), null);
}
}
// parent, = =
if (child.getParent() != null) {
return;
}
}
public boolean cancelLayoutTransition(ViewGroup group) {
if (group != null) {
final LayoutTransition layoutTransition = group.getLayoutTransition();
if (layoutTransition != null && layoutTransition.isRunning() &&
METHOD_LAYOUT_TRANSITION_CANCEL != null) {
// cancel @hide,
ReflectionUtils.invoke(group.getLayoutTransition(), null, ReflectionUtils.getPrivateMethod(LayoutTransition.class, "cancel"));
return true;
}
}
return false;
}