I’ve found a solution. I had to clear fragment’s parent from views before destroying and I’ve used the next peace of code for this:
in Java
public void onDestroyView() {
if (rootView != null){
ViewGroup viewGroup = (ViewGroup)rootView.getParent();
if (viewGroup != null){
viewGroup.removeAllViews();
}
}
super.onDestroyView();
}
in Kotlin
override fun onDestroyView() {
if (rootView != null) {
val viewGroup = rootView.parent as ViewGroup?
viewGroup?.removeAllViews();
}
super.onDestroyView()
}