title: Android fragments overlap previous view and button listeners
body: <p>I have an activity A with a fragment A inside.</p>
  
  <p>Activity A uses layout X, and fragment A uses layout A. </p>
  
  <p>code of layout X:</p>
  
  <pre><code>&lt;RelativeLayout 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;fragment
      android:id="@+id/fragment1"
      android:name="android.app.DialogFragment"
      android:layout_width="wrap_content"
      android:layout_height="500dp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="113dp"
      class="com.example.fragtester.FragA" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Layout A is just textview + linearlayout.</p>
  
  <p>I set up another fragment B that uses layout B.</p>
  
  <p>Now that I use the following code in activity A to change the fragments:</p>
  
  <pre><code>Fragment f = new FragB();
  FragmentTransaction ft = getFragmentManager().beginTransaction();
  ft.replace(R.id.fragment1, f);
  ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
  ft.addToBackStack(null); 
  ft.commit();
  </code></pre>
  
  <p>I end up having layout B displaying under layout A.</p>
  
  <p>So I use a FrameLayout to wrap the fragment in layout X and use</p>
  
  <pre><code>ft.replace(R.id.FrameLayout1, f);
  </code></pre>
  
  <p>Now the view is working nicely. Though, another problem arises.</p>
  
  <p>Although layout B covers layout A, but the buttons are still active.</p>
  
  <p>That means when I am viewing layout B, I can still click buttons on layout A, even if I am not seeing it.</p>
  
  <p>And even when I add fragment C/D/E..... (layouts C/D/E....), the buttons on layout A is still active.</p>
  
  <p>Can anybody explain why is that? Am I using fragments wrongly? Thanks!</p>
  
  <p>A way to get through is to make layout A blank, and use other layout to cover it. But it doesn't seems to be the "right" way??</p>