【问题标题】:Why does my image doesn't show in imageView?为什么我的图像没有显示在 imageView 中?
【发布时间】:2021-10-10 02:12:13
【问题描述】:

所以我正在使用 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>

但是当我运行应用程序时,图像没有出现。它应该是 like this,但它看起来是 like this。是不是因为图片太大?(我从谷歌图片下载了img)。如何解决这个问题?

【问题讨论】:

    标签: xml imageview android-imageview android-cardview


    【解决方案1】:

    你可以试试这个

    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"
    />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-12
      • 2021-03-31
      • 2018-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多