【发布时间】:2021-01-03 04:12:16
【问题描述】:
我正在使用一个 Cardview,它在 Android 中具有一个用于 RecyclerView 的 ImageView。不幸的是,CardView 不会缩放图像,这意味着小图像会导致 RecyclerView 中的项目更小。在这里你有一个截图,我使用了两个不同的 ImageResources(一个大的和一个小的):
这是 CardView 的 XML 代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="5dp"
app:cardElevation="0dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="true"
app:contentPadding="0dp"
card_view:cardBackgroundColor="@android:color/transparent"
app:contentPaddingBottom="0dp"
app:contentPaddingLeft="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp"
android:adjustViewBounds="true"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
我尝试对 ImageView(和 LinearLayout)的属性使用“wrap_content”,并尝试包含属性“android:scaleType="fitXY”,但它没有帮助,似乎也没有任何效果。
有人介意帮助我吗?非常感谢您的每一条评论,并非常感谢您的帮助。
【问题讨论】:
-
制作
CardView宽度match_parent
标签: android android-recyclerview android-cardview