[android] ImageView - have height match width?

Update: Sep 14 2017

According to a comment below, the percent support library is deprecated as of Android Support Library 26.0.0. This is the new way to do it:

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        app:layout_constraintDimensionRatio="1:1" />

</android.support.constraint.ConstraintLayout>

See here

Deprecated:

According to this post by Android Developers, all you need to do now is to wrap whatever you want within a PercentRelativeLayout or a PercentFrameLayout, and then specify its ratios, like so

<android.support.percent.PercentRelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        app:layout_widthPercent="100%"
        app:layout_aspectRatio="100%"/>

</android.support.percent.PercentRelativeLayout>