title: Is it possible to centre the actionbar title from a fragment using AndroidX navigation?
body: <p>Currently, I am using the <a href="https://developer.android.com/guide/navigation/navigation-getting-started" rel="nofollow noreferrer">Navigation</a> component from Android and the actionbar title is displayed on the left. However, I kind of want it centralised to make things neater, is there any way to go about doing so?</p>
  <p><a href="https://i.stack.imgur.com/oWTOt.png" rel="nofollow noreferrer">Image of the actionbar title that is displayed on the left</a></p>
  <p>Activity's code:</p>
  <pre><code>public class General extends AppCompatActivity {
      private BottomNavigationView bottomNavigationView;
      private NavController navController;
      private AppBarConfiguration appBarConfiguration;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.general);
  
          bottomNavigationView = findViewById(R.id.bottomNavigationView);
          navController = Navigation.findNavController(this,  R.id.fragment);
  
          appBarConfiguration = new AppBarConfiguration.Builder(R.id.addFragment, R.id.homeFragment).build();
  
          NavigationUI.setupWithNavController(bottomNavigationView, navController);
          NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
      }
  }
  </code></pre>
  <p>Activity's XML Code</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:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.General&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_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:menu=&quot;@menu/bottom_navigation_menu&quot;&gt;
  
      &lt;/com.google.android.material.bottomnavigation.BottomNavigationView&gt;
  
      &lt;fragment
          android:id=&quot;@+id/fragment&quot;
          android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;0dp&quot;
          app:defaultNavHost=&quot;true&quot;
          app:layout_constraintBottom_toTopOf=&quot;@+id/bottomNavigationView&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot;
          app:navGraph=&quot;@navigation/the_navigation&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>Fragment XML Code:</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/the_navigation&quot;
      app:startDestination=&quot;@id/homeFragment&quot;&gt;
  
      &lt;fragment
          android:id=&quot;@+id/homeFragment&quot;
          android:name=&quot;com.test.HomeFragment&quot;
          android:label=&quot;Home&quot;
          tools:layout=&quot;@layout/home_fragment&quot; /&gt;
      &lt;fragment
          android:id=&quot;@+id/addFragment&quot;
          android:name=&quot;com.test.AddFragment&quot;
          android:label=&quot;Add&quot;
          tools:layout=&quot;@layout/add_fragment&quot; /&gt;
  &lt;/navigation&gt;
  </code></pre>