Caused by: java.lang.IllegalStateException: The specified child already has a parent.
You must call removeView() on the child's parent first.
所以让我们说,layoutmanager是你的布局实例,然后你需要这样做:
RelativeLayout layoutManager = new RelativeLayout(this);
ImageView image = new ImageView(this);
// this line worked for me
layoutManager.removeView(image);