I have an imageview in Linearlayout I want its width to be fill_parent. I want its height to be whatever the width ends up being. For example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="1:1"
android:scaleType="centerCrop"
android:layout_margin="2dp"
tools:ignore="Suspicious0dp" />
</LinearLayout>
But it doesn't show the images in the android layout.. If I force change height of the imageview to 100dp in the code, it works, but I wonder why the height of image doesn't match to width even I wrote constraintDimensionRatio 1:1..
Thank you