title: ConstraintLayout in Toolbar not applying match_parent for width or height
body: <p>I have a <code>Toolbar</code> at the top of my app which contains a <code>ConstraintLayout</code> which in turn contains an <code>ImageView</code>, a <code>TextView</code> and another <code>TextView</code> (the title). I want the title to be centered inside the <code>Toolbar</code> so i set the title's constraints to be equal (8 and 8) on both sides. But after running the app and checking the layout preview in Android studio i realized that despite the <code>ConstraintLayout</code> having the <code>android:layout_width="match_parent"</code> and <code>android:layout_height="match_parent"</code> attributes, it does not take up the appropriate space thus causing the centering of the title to be off (see image). Any ideas on what i'm missing?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_height="match_parent"
      android:layout_width="match_parent"&gt;
  
      &lt;androidx.appcompat.widget.Toolbar
          android:id="@+id/home_toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@drawable/home_toolbar_gradient"
          android:elevation="4dp"
          android:minHeight="70dp"
          android:theme="@style/AppTheme"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"&gt;
  
          &lt;androidx.constraintlayout.widget.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              tools:layout_editor_absoluteX="16dp"
              tools:layout_editor_absoluteY="19dp"&gt;
  
              &lt;ImageView
                  android:id="@+id/weatherImg"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_marginStart="8dp"
                  android:layout_marginTop="8dp"
                  android:layout_marginBottom="8dp"
                  android:contentDescription="weather"
                  android:src="@mipmap/weather_placeholder_icon"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"
                  tools:ignore="HardcodedText" /&gt;
  
              &lt;TextView
                  android:id="@+id/weatherTxt"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="start"
                  android:layout_marginStart="8dp"
                  android:fontFamily="@font/montserrat_bold"
                  android:gravity="start"
                  android:text="@string/home_weather_text_placeholder"
                  android:textAlignment="center"
                  android:textColor="@android:color/white"
                  android:textSize="15sp"
                  app:layout_constraintBottom_toBottomOf="@+id/weatherImg"
                  app:layout_constraintStart_toEndOf="@+id/weatherImg"
                  app:layout_constraintTop_toTopOf="@+id/weatherImg" /&gt;
  
              &lt;TextView
                  android:id="@+id/title_home"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center"
                  android:layout_marginStart="8dp"
                  android:layout_marginEnd="8dp"
                  android:fontFamily="@font/montserrat_bold"
                  android:gravity="center"
                  android:text="@string/home"
                  android:textAlignment="center"
                  android:textColor="@android:color/white"
                  android:textSize="18sp"
                  app:layout_constraintBottom_toBottomOf="@+id/weatherImg"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="@+id/weatherImg" /&gt;
  
          &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
      &lt;/androidx.appcompat.widget.Toolbar&gt;
  
      &lt;!-- Using a view with a gradient to create a drop navbar_shadow effect for the navbar --&gt;
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="4dp"
          android:layout_above="@id/bottom_nav_bar"
          android:background="@drawable/navbar_shadow"
          app:layout_constraintBottom_toTopOf="@+id/bottom_nav_bar"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent" /&gt;
  
      &lt;com.google.android.material.bottomnavigation.BottomNavigationView
          android:id="@+id/bottom_nav_bar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          app:itemBackground="@android:color/white"
          app:itemIconTint="@drawable/nav_selected_item_color"
          app:itemTextColor="@drawable/nav_selected_item_color"
          app:labelVisibilityMode="labeled"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:menu="@menu/bottom_nav_bar"&gt;
  
  
      &lt;/com.google.android.material.bottomnavigation.BottomNavigationView&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt; 
  </code></pre>
  
  <p>P.S: I don't know if this matters but i also have a <code>menu</code> for the toolbar which contains an item with the attribute <code>showAsAction="always"</code></p>
  
  <p><a href="https://i.stack.imgur.com/WXjmd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WXjmd.png" alt="layout_preview"></a></p>