title: Text from fragment is showing up inside my navbar
body: <p>i have been trying to fix this error but cant get it to work.
  <a href="https://i.stack.imgur.com/JbcvF.png" rel="nofollow noreferrer">Here you find a picture of my problem</a> the problem is that my text of the fragment is showing up in the navbar. i hope somebody can help me out with this!</p>
  <p>activity_main code xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  
  &lt;androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/coordinatorLayout&quot;
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_above=&quot;@id/bottomNavigationView&quot;&gt;
      &gt;
  
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;TextView
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Sander's app&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.036&quot; /&gt;
  
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id=&quot;@+id/bottomNavigationView&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintHorizontal_bias=&quot;0.0&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:layout_constraintVertical_bias=&quot;0.998&quot;
          app:menu=&quot;@menu/bottom_menu&quot;&gt;
  
          &lt;androidx.fragment.app.FragmentContainerView
              android:id=&quot;@+id/fragmentContainerView&quot;
              android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              app:defaultNavHost=&quot;true&quot;
              app:navGraph=&quot;@navigation/my_nav&quot; /&gt;
      &lt;/com.google.android.material.bottomnavigation.BottomNavigationView&gt;
  
      &lt;EditText
          android:id=&quot;@+id/editTextTextPersonName&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;103dp&quot;
          android:ems=&quot;10&quot;
          android:inputType=&quot;textPersonName&quot;
          android:text=&quot;&quot;
          android:background=&quot;#fff&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintLeft_toLeftOf=&quot;parent&quot;
          app:layout_constraintRight_toRightOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          tools:layout_editor_absoluteX=&quot;16dp&quot;
          tools:layout_editor_absoluteY=&quot;121dp&quot; /&gt;
  
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
      &lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;
  </code></pre>
  <p>MainActiviy java code:</p>
  <pre><code>package com.example.myapp;
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  
  
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.EditText;
  
  import com.google.android.material.bottomnavigation.BottomNavigationView;
  import com.google.android.material.floatingactionbutton.FloatingActionButton;
  import com.google.android.material.snackbar.Snackbar;
  
  
  public class MainActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener {
      private Button button;
  
      public static final String EXTRA_TEXT = &quot;com.example.myapp.EXTRA_TEXT&quot;;
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  //        FloatingActionButton fab = findViewById(R.id.bottomNavigationView);
  //        final View v = findViewById(android.R.id.content);
  //        Snackbar snackbar = Snackbar.make(v, &quot;Welkom terug gebruiker!&quot;, Snackbar.LENGTH_LONG);
  //        snackbar.setAnchorView(fab);
  //        snackbar.show();
  
  
          setContentView(R.layout.activity_main);
  
          BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
          bottomNavigationView.setOnNavigationItemSelectedListener(this);
          bottomNavigationView.setSelectedItemId(R.id.firstFragment);
  
  
  
  
  
  
      }
      FirstFragment firstFragment = new FirstFragment();
      SecondFragment secondFragment = new SecondFragment();
      ThirdFragment thirdFragment = new ThirdFragment();
  
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  
          switch (item.getItemId()) {
              case R.id.home:
                  getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, firstFragment).commit();
                  return true;
  
              case R.id.games:
                  getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, secondFragment).commit();
                  return true;
  
              case R.id.maps:
                  getSupportFragmentManager().beginTransaction().replace(R.id.fragmentContainerView, thirdFragment).commit();
                  return true;
          }
          return false;
  
      }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
      public void openSecondActivity() {
          EditText editTextTextPersonName = (EditText) findViewById(R.id.editTextTextPersonName);
          String text = editTextTextPersonName.getText().toString();
          Intent intent = new Intent(MainActivity.this, SecondActivity.class);
          intent.putExtra(EXTRA_TEXT, text);
  
          startActivity(intent);
  
      }
  
  
  
      }
  </code></pre>
  <p>fragment_second xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/secondFragment&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.SecondFragment&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textView6&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Second activity&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          tools:layout_editor_absoluteX=&quot;158dp&quot; /&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>SecondFragment java</p>
  <pre><code>package com.example.myapp;
  
  import android.os.Bundle;
  
  import androidx.fragment.app.Fragment;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import com.google.android.material.snackbar.Snackbar;
  
  /**
   * A simple {@link Fragment} subclass.
   * Use the {@link SecondFragment#newInstance} factory method to
   * create an instance of this fragment.
   */
  public class SecondFragment extends Fragment {
  
      // TODO: Rename parameter arguments, choose names that match
      // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
      private static final String ARG_PARAM1 = &quot;param1&quot;;
      private static final String ARG_PARAM2 = &quot;param2&quot;;
  
      // TODO: Rename and change types of parameters
      private String mParam1;
      private String mParam2;
  
      public SecondFragment() {
          // Required empty public constructor
      }
  
      /**
       * Use this factory method to create a new instance of
       * this fragment using the provided parameters.
       *
       * @param param1 Parameter 1.
       * @param param2 Parameter 2.
       * @return A new instance of fragment SecondFragment.
       */
      // TODO: Rename and change types and number of parameters
      public static SecondFragment newInstance(String param1, String param2) {
          SecondFragment fragment = new SecondFragment();
          Bundle args = new Bundle();
          args.putString(ARG_PARAM1, param1);
          args.putString(ARG_PARAM2, param2);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              mParam1 = getArguments().getString(ARG_PARAM1);
              mParam2 = getArguments().getString(ARG_PARAM2);
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  //        View v = getActivity().findViewById(android.R.id.content);
  //        Snackbar.make(v, &quot;U bent nu in games.&quot;, Snackbar.LENGTH_SHORT).show();
  
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_second, container, false);
      }
  }
  </code></pre>
  <p>bottom_menu xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;menu xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
  
      &lt;item
          android:id=&quot;@+id/home&quot;
          android:title=&quot;Home&quot;
          android:icon=&quot;@drawable/ic_home&quot;/&gt;
      &lt;item
          android:id=&quot;@+id/games&quot;
          android:title=&quot;Games&quot;
          android:icon=&quot;@drawable/ic_games&quot;/&gt;
      &lt;item
          android:id=&quot;@+id/maps&quot;
          android:title=&quot;Maps&quot;
          android:icon=&quot;@drawable/ic_map&quot; /&gt;
  &lt;/menu&gt;
  </code></pre>
  <p>my_nav xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/my_nav&quot;
      app:startDestination=&quot;@id/firstFragment&quot;&gt;
  
      &lt;fragment
          android:id=&quot;@+id/firstFragment&quot;
          android:name=&quot;com.example.myapp.FirstFragment&quot;
          android:label=&quot;fragment_first&quot;
          tools:layout=&quot;@layout/fragment_first&quot; /&gt;
      &lt;fragment
          android:id=&quot;@+id/secondFragment&quot;
          android:name=&quot;com.example.myapp.SecondFragment&quot;
          android:label=&quot;fragment_second&quot;
          tools:layout=&quot;@layout/fragment_second&quot; /&gt;
      &lt;fragment
          android:id=&quot;@+id/thirdFragment&quot;
          android:name=&quot;com.example.myapp.ThirdFragment&quot;
          android:label=&quot;fragment_third&quot;
          tools:layout=&quot;@layout/fragment_third&quot; /&gt;
  &lt;/navigation&gt;
  </code></pre>
  <p>I hope somebody can help because i have been trying for hours</p>