title: Activity layout is still visible after adding fragment to the activity
body: <p>This is a really lame question, but I really cannot figure out why it happens, so please help me out.</p>
  
  <p>I have a simple <strong>activity</strong> and I add a <strong>fragment</strong> to it <strong>dynamically</strong>. The problem is that once the <strong>fragment</strong> is added to the <strong>activity</strong>, the <strong>activity</strong> layout is also visible. Why does this happen? </p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button btnLoad = (Button) findViewById(R.id.btn1);
  
      View.OnClickListener listener = new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              FragmentManager fragmentManager = getFragmentManager();
              FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
              HelloFragment hello = new HelloFragment();
              fragmentTransaction.add(R.id.rootView, hello, "HELLO");
              fragmentTransaction.commit();
          }
      };
  
      btnLoad.setOnClickListener(listener);
  } 
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" tools:context=".MainActivity"&gt;
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/rootView"
      android:orientation="vertical"&gt;
      &lt;TextView
          android:text="@string/hello_world"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
      &lt;Button
          android:id="@+id/btn1"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:text="OK"/&gt;
  &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>HelloFragment.java</strong></p>
  
  <pre><code>public class HelloFragment extends Fragment {
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, 
  Bundle savedInstanceState) {                       
      /** Inflating the layout for this fragment **/
      View v = inflater.inflate(R.layout.hello_fragment_layout, null);
      return v;
  }
  }
  </code></pre>
  
  <p><strong>hello_fragment_layout.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"      
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;
    &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:text="fragment 1"/&gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BBjQS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BBjQS.png" alt="asfasfsdadgsgsagsag"></a></p>
  
  <p><a href="https://i.stack.imgur.com/4xnES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4xnES.png" alt="After adding fragment"></a></p>