xml - 为什么我的图像没有显示在 imageView 中?
问题描述
所以我正在使用 android studio 处理我的项目。我用 CardView 创建了一个简单的 xml,并在其中使用了 ImageView。代码如下:
<androidx.cardview.widget.CardView
android:layout_width="120dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="20dp"
app:cardElevation="3dp"
app:cardMaxElevation="20dp">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:srcCompat="@drawable/vector_illustration" />
</androidx.cardview.widget.CardView>
但是当我运行应用程序时,图像不会出现。它应该看起来像这样,但它看起来 像这样。是不是因为图片太大?(我从谷歌图片下载了img)。如何解决这个问题?
解决方案
你可以试试这个
xmlns:app="http://schemas.android.com/apk/res-auto"
.
...
...
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="@drawable/vector_illustration"
/>
推荐阅读
- r - ggplot2 包中的闪避点不起作用
- javascript - 如何编写一个每 30 分钟运行一次的 Javascript 函数
- php - 我在线托管的 Codeigniter 4 项目显示未指定输入文件
- javascript - 当 AppBar 在 div 内时,如何使 AppBar 隐藏并显示在滚动条上?
- python - 用于在字符串中查找子字符串的 Pandas if 语句
- amazon-web-services - 从 VPC 内将“禁止”异常发布到 API Gateway Websocket API
- r - 如何执行算术运算的所有可能组合?
- node.js - Sails-hook-babel 导致 Sails 应用程序出错
- python - 字符串连接以防止两个字符串在内存中移动
- java - 重新保存修改后的对象时,JPA 合并()无法按预期工作