Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play gif in android from url?

I want to play animated gif from url in android app like imgur app. Imagur is superb and very fast. I am loading gif with webview but its not up to the mark.

like image 866
user3606902 Avatar asked Jan 02 '16 05:01

user3606902


People also ask

How can I play GIFs on my Android?

Android smartphones have a built-in image viewing application called Gallery. When you connect your Android smartphone to your computer and transfer a GIF file to your phone's storage area, you can open the Gallery appliation and view that GIF file.

How do I open a GIF from a website?

GIFs are also easy to open through web-based browsers, including Chrome, Firefox, and Internet Explorer. In the case of Internet Explorer, simply click on the File menu and then Open. Select Browse followed by All Files. Click on the GIF file name and then Open.

How do you use a GIF link?

Once you click on the selected GIF, you will be directed to the GIF detail page. Click “< > Embed” located on the right hand side of the GIF. From there, you be presented with two embed options via the GIPHY Embed Player: Select the “Responsive Off” switch for the iFrame embed version.

How do I get my GIF to play?

To play animated GIF files, you must open the files in the Preview/Properties window. To do this, select the animated GIF file, and then on the View menu, click Preview/Properties. If the GIF does not play, try re-saving the animated GIF in the collection in which you want to put it.


1 Answers

You can use Glide to play gif on ImageView. So, let's add it to your app's gradle:

repositories {
    mavenCentral()
}

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

Then, create an ImageView:

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

In your activity:

Glide  
    .with(context) // replace with 'this' if it's 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);

For more information, open this post Glide — Displaying Gifs & Videos.

like image 57
Anggrayudi H Avatar answered Sep 24 '22 00:09

Anggrayudi H