提问人:Satyam Thakur 提问时间:6/13/2023 更新时间:6/13/2023 访问量:21
根据 ImageSize 调整项目卡的大小
Resizing item cards according to ImageSize
问:
我正在开发这个模因应用程序,它从 api 中获取一些 mmeme 图像并将其显示在 recyclerview 的项目中。图像大小不同,我希望项目的卡片根据图像的大小动态调整大小,请让我知道我有哪些选项可以实现这一目标,我还有一个圆形进度条作为滑动的占位符。
目前,我已将 imageView 的高度设置为固定的 300dp。
<ImageView
android:id="@+id/meme_image"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="8dp"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/meme_user_title"
tools:srcCompat="@tools:sample/avatars" />
这是我对滑翔所做的
Glide.with(context)
.load(memes[position].url)
.placeholder(circularProgressDrawable)
.transition(DrawableTransitionOptions.withCrossFade())
.into(holder.img)
我尝试将 imageView 高度设置为换行内容,但它看起来很奇怪,因为图像会立即弹出,看起来不太好。我希望图像在滑动占位符开始时具有一定的高度,并且当加载图像时,它应该将自身大小调整为图像的大小。此外,我想要 ImageView 的最大高度,以便如果图像非常大,那么它不应该在屏幕上占据整个视图。
评论