title: Fragment is overlapping
body: <p>I have created an app when i'm testing my app or i clicked on back button my fragment is overlapping other fragment. I don't know why it's happening. Please help me i need help..
  My codes</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private SharedPreferences pref;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          pref = getPreferences(0);
          initFragment();
      }
  
      private void initFragment(){
          Fragment fragment;
          if(pref.getBoolean(Constants.IS_LOGGED_IN,false)){
              fragment = new ProfileFragment();
          }else {
              fragment = new LoginFragment();
          }
          FragmentTransaction ft = getFragmentManager().beginTransaction();
          ft.replace(R.id.fragment_frame,fragment);
          ft.commit();
      }
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout 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"
      android:fitsSystemWindows="true"
      android:background="#ff51b46d"
      tools:context="com.example.hldev.docup.MainActivity"&gt;
  
      &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="com.example.hldev.docup.MainActivity"&gt;
  
          &lt;FrameLayout
              android:id="@+id/fragment_frame"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>Uploads.java</p>
  
  <pre><code>     public class Uploads extends Fragment implements View.OnClickListener{
  
              @Nullable
              @Override
              public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
                View view=inflater.inflate(R.layout.activity_uploads, container, false);
                  ivAttachment = (ImageView)view.findViewById(R.id.ivAttachment);
  
                  tv_name = (TextView)view.findViewById(R.id.tv_name);
                  tv_email = (TextView)view.findViewById(R.id.tv_email);
                  bUpload = (Button)view.findViewById(R.id.b_upload);
                  tvFileName = (TextView)view.findViewById(R.id.tv_file_name);
                  ivAttachment.setOnClickListener(this);
                  bUpload.setOnClickListener(this);
                  return  view;
              }
  
  
   private void goToProfile(){
  
          Fragment profile = new ProfileFragment();
          FragmentTransaction ft = getFragmentManager().beginTransaction();
          ft.replace(R.id.fragment_frame,profile);
          ft.commit();
      }
      }
  </code></pre>