Center align behavior in ConstraintLayout

Viewed 81

I have an image with same width and height which is 60% of the device's width. I want the vertical center of the image to be 45% of the device's height. My code is below: enter image description here

I have set constraintTop and constraintBottom to the guideline, but it just like the constraintBottom does not work. The image is just at the bottom of the guideline. I don't know what's wrong with my code.

I have tried to replace 'android.support.constraint.ConstraintLayout' to 'androidx.constraintlayout.widget.ConstraintLayout',the result is still not expected: enter image description here

I fill the image with blue color to illustrate the problem and the result on my cellphone: enter image description here

1 Answers

This occurs in version 1.1.3 of ConstraintLayout and is, somehow, related to the dimensions of 0dp and the setting of app:layout_constraintDimensionRatio="1:1". This does not occur in version 2.0.4, so upgrade to that release if you can.

Related