0
layout1.addView(newView);
layout2.addView(newView);

When I run this code I get the error

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

Is there any possible way to add the newly created view to 2 parent views?

KANAYO AUGUSTIN UG
  • 1,877
  • 1
  • 14
  • 27
  • No, as error states each view can only have one parent. You have to create another instance of it if you want to have it in two places. – Pawel Sep 06 '21 at 09:40

0 Answers0