title: How to centre 2 elements in a constraint layout, which have different heights
body: <p>I am trying to centre elements in a constraint layout, I could use a guide line to be centred and then place the image and textview up and below it, but image and textview are of different height so they would not be centred.</p>
  <p>any best approach on this please</p>
  <pre><code>         &lt;androidx.constraintlayout.widget.ConstraintLayout
                      android:id=&quot;@+id/noDataMessageLayout&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginHorizontal=&quot;@dimen/margin_horizontal_small&quot;
                      android:layout_marginBottom=&quot;@dimen/margin_vertical_small&quot;
                      android:visibility=&quot;visible&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                      app:layout_constraintTop_toBottomOf=&quot;@+id/monthSpinner&quot;
                      app:layout_constraintBottom_toTopOf=&quot;@+id/monthlyChargeConsumptionLayout&quot;&gt;
  
                      &lt;ImageView
                          android:id=&quot;@+id/noDataImage&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:src=&quot;@drawable/ic_no_data&quot;
                          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                          app:layout_constraintStart_toStartOf=&quot;parent&quot;
                          app:layout_constraintTop_toTopOf=&quot;parent&quot;
                          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;/&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/noDataMessageTV&quot;
                          style=&quot;@style/Text.Small.Light&quot;
                          android:layout_width=&quot;wrap_content&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_marginVertical=&quot;@dimen/margin_vertical_small&quot;
                          android:gravity=&quot;center_vertical&quot;
                          android:text=&quot;No charge session data\navailable for this month.&quot;
                          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                          app:layout_constraintStart_toStartOf=&quot;parent&quot;
                          app:layout_constraintTop_toBottomOf=&quot;@+id/noDataImage&quot; /&gt;
                  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>This is how it looks at the moment.</p>
  <p>Thanks for your help in advance
  R</p>
  <p><a href="https://i.stack.imgur.com/hNkiM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNkiM.png" alt="enter image description here" /></a></p>