I'm using a linearlayout in an AlertDialog. I'm trying to use as much space as possible for the image, so I want to use layout_weight="1" to make it grow. I've been using a plain view before and it worked fine, but since I'm now trying to display an image, I'd like to use an ImageView. But the ImageView always has height 0, unless I initialize it with a specific image. But when I change the image afterwards with Glide, the size shrinks to zero again.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_layout"
style="@style/TextInputOutlinedStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="4dp"
app:hintEnabled="true"
android:hint="@string/signature_picker_fullname_hint">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
This is how I load the image:
Glide.with(this.requireContext())
.load(this.initialSignature.getUri())
.into(this.imageView);
I've tried playing around with adjustViewBounds and scaleTypes and different timings to load the image, but nothing worked.