android - 卡片视图中的图像未完全填充
问题描述
我有这个带有图像的卡片视图,但问题是,图像没有填满卡片,我不确定为什么会发生这种情况(改变宽度似乎没有任何影响)。
这是xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="180dp"
android:layout_height="130dp"
app:cardCornerRadius="16dp"
app:strokeColor="@color/white">
<ImageView
android:id="@+id/iv_news"
android:layout_width="250dp"
android:layout_height="130dp"
android:layout_marginStart="10dp"
android:background="@drawable/card_background_shape"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/tv_title"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:gravity="center"
android:text="@string/news_title"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" />
</LinearLayout>
解决方案
推荐阅读
- java - 每次尝试执行此操作时都会失败
- javascript - Javascript:onmouseover 和 onmouseout 图像不透明度更改
- c# - C#如何将这些代码行中的0和1识别为num 1和num2?
- objective-c - iOS 13 NSNumberFormatter 货币小数
- c# - 将 ASP.NET MVC(无实体框架)项目与另一个基于实体框架的项目结合起来
- java - 是否有更好的方法来分区列表和批量处理以更改源列表
- java - 有没有办法将导致值的 ArrayIndexOutOfBoundsException 替换为某个默认值?
- python - 如何检查python中非空列的约束?
- google-cloud-run - Google Cloud Run 上的 500:请求失败,因为实例无法成功启动
- python - Django:登录时创建新用户时用户名为空