title: replace fragment with another fragment along with remove view
body: <p>I have one activity and two Fragments. FragmentA and FragmentB.</p>
  
  <p>I need to implement like, Initially  FragmentA should be there. 
  and After <code>Button</code> click FragmentB should be there.</p>
  
  <p>in my condition when activity is being displayed,fragmentA is showing and when click to button,fragmentB placed at the bottom of fragmentA and do not replace FragmentA</p>
  
  <p>My activity Code is:</p>
  
  <pre><code>public class FragmentActivity extends AppCompatActivity {
  
  FrameLayout activityFragment;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_fragment);
      activityFragment = (FrameLayout) findViewById(R.id.activityFragment);
      Fragment fragment = new FragmentA();
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      transaction.add(R.id.activityFragment, fragment);
      transaction.commit();
  }
  
  public void goToFrag(View view) {
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      Fragment fragment = new FragmentB();
      transaction.add(R.id.fragmentRoot, fragment);
      transaction.commit();
  }
  }
  </code></pre>
  
  <p>my first fragment code:</p>
  
  <pre><code>  public class FragmentA extends Fragment {
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      super.onCreateView(inflater, container, savedInstanceState);
      View view=inflater.inflate(R.layout.fragment_a,container,false);
      return view;
  }
  }
  </code></pre>
  
  <p>my second fragment code:</p>
  
  <pre><code>   public class FragmentB extends Fragment {
  public FragmentB() {
  }
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       super.onCreateView(inflater, container, savedInstanceState);
      View view=inflater.inflate(R.layout.fragment_b,container,false);
      return view;
  }
  }
  </code></pre>