AndroidのImageViewにgif画像を追加する 質問する

AndroidのImageViewにgif画像を追加する 質問する

imageView にアニメーション GIF 画像を追加しました。GIF 画像として表示できません。アニメーションはありません。静止画像として表示されます。GIF 画像として表示する方法を知りたいです。

ベストアンサー1

build.gradle(Module:app)に以下を追加android-gif-drawable次のコードを追加して依存関係として追加します。

allprojects {
    repositories {
       mavenCentral()
    }
}

dependencies {
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
}


アップデート : 現在 Android Gradle プラグイン 3.0.0 、コンパイル用の新しいコマンドは なので implementation 、上記の行を次のように変更する必要があるかもしれません。

dependencies {
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
}

次に、プロジェクトを同期します。同期が終了したら、レイアウト ファイルに移動して次のコードを追加します。

<pl.droidsonroids.gif.GifImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/gif_file"
/>

これで完了です。シンプルな ImageView で管理できます。

おすすめ記事