Android: Keep ratio for a full-width and undefined height ImageView in a ConstraintLayout?

前端 未结 2 1040
灰色年华
灰色年华 2021-01-24 08:01

In a ConstraintLayout, an ImageView is bound to its parent in such a way that:

  1. Its left side is bound to the screen\'s left side

2条回答
  •  感动是毒
    2021-01-24 08:12

    I think that you can use app:layout_constraintDimensionRatio="your ratio" to keep the aspect ratio if your image

    For example, if you want square you need the same width and height so use - app:layout_constraintDimensionRatio="1:1"

提交回复
热议问题