I have a question that whenever i open a new fragment from another fragment it open up but when i come back by back button then why does it holds the background view of the previous fragment, if i add this piece of code to that fragment if 

```
(container != null) {
        container.removeAllViews();
    }

```

then it gets out on whole screen where i want it to be under the toolbar, it gets out of it and toolbar is not shown and sometimes app stops also.
I am a newbie to fragments so please answer my question in a calm and detailed way.
I have added a flow of how screens are appearing and this are fragments except first one,when it comes to 2nd again that time the screen looks partially like another.[![this is the flow of all the screens](https://i.stack.imgur.com/S3bmH.png)](https://i.stack.imgur.com/S3bmH.png)[![this is the screen when flow goes from fourth to second fragment, partial scrren visibility problem as i want to show the background fully only and not the table layout onewhich is appearing over it](https://i.stack.imgur.com/aNdlH.jpg)](https://i.stack.imgur.com/aNdlH.jpg)

I use this code to add fragments on click of buttons

```
 Addhearingnewfrag fragment = new Addhearingnewfrag();
            FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.replace(R.id.contentFragment, fragment);
            fragmentTransaction.addToBackStack(null);
            fragmentTransaction.commit();
        }
    });

```