I'm having the same problem as this question but the answers there don't solve the problem. I've subclassed ImageView, and overriden onMeasure like so:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
this.setMeasuredDimension(this.getMeasuredHeight(), this.getMeasuredHeight());
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
This doesn't change anything, and if I try using the code from the answers of the linked post, the ImageView becomes invisible (0 width/height) because the heightMeasureSpec is 0, and MeasureSpec.getSize(heightMeasureSpec) is also 0.
The goal is to have the ImageView be as tall as the parent view, and have the width be the same (as the image is square).
Edit: here is my ImageView in the layout XML:
<ImageView
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/bottomtext"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/toptext"
android:adjustViewBounds="true"
android:padding="4dp"
android:scaleType="centerCrop" />
No need to subclass the `ImageView'. Just do this