Подтвердить что ты не робот

Как играть в gif в android из url?

Я хочу играть в анимированный gif из url в Android-приложении, таком как приложение imgur. Imagur превосходно и очень быстро. Я загружаю gif с webview, но это не соответствует значению.

4b9b3361

Ответ 1

Вы можете использовать Glide для воспроизведения gif на ImageView. Итак, добавьте его в свое приложение gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support:support-v4:23.1.1'
}

Затем создайте ImageView:

<ImageView
    android:id="@+id/imageView"
    android:contentDescription="@string/content"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

В вашей деятельности:

Glide  
    .with(context) // replace with 'this' if it in activity
    .load("http://www.google.com/.../image.gif")
    .asGif()
    .error(R.drawable.error_image) // show error drawable if the image is not a gif
    .into(R.id.imageView);

Для получения дополнительной информации откройте этот пост Glide - Отображение Gif и видео.

Ответ 2

Вы можете установить изображение как:

           <com.example.androidgif.GifView
            android:id="@+id/gifview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

Следуя этому руководству, вы можете сделать это:

http://android-er.blogspot.de/2014/03/load-animated-gif-from-internet.html