Android play .gif file on imageview in aide ide

aide ide tutorials

In this tutorial we are playing .gif files on imageview in our android app project in aide ide,  the default imageview is not support playing .gif files, for fast and easy way im using glide library.

Glide is an Image Loader Library for Android developed by bumptech and is a library that is recommended by Google. It has been used in many Google open source projects including Google I/O 2014 official application. It provides animated GIF support and handles image loading/caching.

First goto your "build.gradle" and add this code below
compile 'com.github.bumptech.glide:glide:3.6.1'

Next goto your java files e.g MainActivity.java and use this following codes below:
private ImageView = imff;

imff=(ImageView)findViewById(R.id.viewthefile_image);

String kakaka5 = "https://giffile_url_here.thatyourlink";
Glide.with(this) // replace with 'this' if it's in activity
.load(kakaka5)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.fallback(R.drawable.main_icon)
.into(imff);
And the last step, in your layout codes:
<ImageView
android:id="@+id/viewthefile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

Other useful code for glide:
Resize , align center and crop:
GlideApp.with(this)
    .load("http://yourgiffule.com")
    .override(100, 200)
    .centerCrop() // scale to fill the ImageView and crop any extra
    .into(imff);
GlideApp.with(this)
    .load("http://yourgiffile.gif")
    .override(100, 200)
    .fitCenter() // scale to fit entire image within ImageView
    .into(imff);
Placeholder and errorimage:
GlideApp.with(this)
    .load("https://sample.pic")
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.imagenotfound)
    .into(imff);
Adding placeholder:
GlideApp.with(this)
    .load("http://sample.com/picici.gif")
    .placeholder(R.drawable.placeholder)
    .error(R.drawable.imagenotfound)
    .into(imff);
Loading error:
GlideApp.with(this)
        .load("http://sample.com/your_file.gif")
        .placeholder(R.drawable.placeholder)
        .error(R.drawable.imagenotfound)
        .listener(new RequestListener<Drawable>() {
            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                // log exception
                Log.e("TAG", "Error loading image", e);
                return false; // important to return false so the error placeholder can be placed
            }

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                return false;
            }
        })
        .into(imff);

Comments

  1. stainless steel plates in stainless steel stainless steel - TITANIA-ART
    Steel plates in titanium jewelry stainless steel guy tang titanium toner stainless steel. titanium mens wedding band Stainless steel titanium tube plates in stainless steel titanium properties stainless steel are the perfect match for your new home.

    ReplyDelete

Post a Comment

Leave a comment hdh

Popular posts from this blog

Implement in-app purchase in aide ide

Implement google admob interstitial ads in aide ide

Android listview with search function using aide ide

Implement google admob banner ads in aide ide

Aide ide tutorial - Add line graph


Malitanyo Developer blog & tutorial 2020
Refund Policy    Facebook Page    Google Play

Blogger.com