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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With