如何解决如何将随机大小的图像完美地拟合到随机大小的图像视图中
您好,我正在尝试添加一个当前宽度为 match_parent 且高度为 0 dp 的图像视图,但我将来可以更改它
现在如何制作将从 Firebase 加载的图像使其完美适合图像视图有什么方法
顺便说一下,我现在正在使用中心裁剪,这很好,但没有太大帮助
这是我的 XML 代码
<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="match_parent"
android:layout_centerInParent="true"
android:weightSum="5"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:id="@+id/Card_View"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_weight="4"
app:shapeAppearanceOverlay="@style/RoundedCornerHome">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/imagePostHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:contentDescription="@string/todo"
app:shapeAppearanceOverlay="@style/RoundedCornerHome" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="0dp"
app:cardBackgroundColor="@color/grey"
android:layout_weight="1"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:background="@color/grey"
app:shapeAppearanceOverlay="@style/RoundedCornerHome">
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
这是从 firebase 加载图像的滑动代码
Glide.with(mcontext)
.load(uploadCurrent.getmImageUrl())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.placeholder(shimmerDrawable)
.centerCrop()
.into(holder.imageView);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。