运行 Android Studio 项目上的 gifImageView

Run gifImageView on Android Studio project

我最近下载了一张 gif 图像,将其插入到我的新 Android Studio 项目中。下载后,我将 .gif 文件复制到 drawable 文件夹中。我称之为"image"。在 activity_main 布局的 "Text" 部分,我这样写:

<ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/image"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        app:layout_constraintVertical_bias="0.498"
        android:layout_marginRight="8dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginLeft="8dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintHorizontal_bias="0.595" />

表面上没有问题......但是当我启动我的应用程序时,gif 不起作用。它像 .jpg 文件图像一样是静态的。如何在我的 Android 手机上播放应用程序中的 .gif 图片?

好吧,使用 imageview 不会做你想做的事。不过有几种查看 gif 的方法。example link or you might simply like to use a library.