Ben aşağıda belirtilen sever yapmak transition drawables & Ölçek türünü, yer tutucunun gerektirdiği şekilde ayarlaması için başlangıç olarak & bağlantı dinleyicisini, istendiği gibi yeniden ölçek türünü değiştirmek üzere ekleyin görüntü indirildikten sonra indirilen görüntü tarafından d. (Eğer bunu gerektirir yoksa son adım atlanabilir)
//ivBuilderLogo = Target ImageView
//Set the scale type to as required by your place holder
//ScaleType.CENTER_INSIDE will maintain aspect ration and fit the placeholder inside the image view
holder.ivBuilderLogo.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//AnimationDrawable is required when you are using transition drawables
//You can directly send resource id to glide if your placeholder is static
//However if you are using GIFs, it is better to create a transition drawable in xml
//& use it as shown in this example
AnimationDrawable animationDrawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
animationDrawable=(AnimationDrawable)context.getDrawable(R.drawable.anim_image_placeholder);
else
animationDrawable=(AnimationDrawable)context.getResources().getDrawable(R.drawable.anim_image_placeholder);
animationDrawable.start();
Glide.with(context).load(logo_url)
.placeholder(animationDrawable)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource)
{
return false;
}
//This is invoked when your image is downloaded and is ready
//to be loaded to the image view
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource)
{
//This is used to remove the placeholder image from your ImageView
//and load the downloaded image with desired scale-type(FIT_XY in this case)
//Changing the scale type from 'CENTER_INSIDE' to 'FIT_XY'
//will stretch the placeholder for a (very) short duration,
//till the downloaded image is loaded
//setImageResource(0) removes the placeholder from the image-view
//before setting the scale type to FIT_XY and ensures that the UX
//is not spoiled, even for a (very) short duration
holder.ivBuilderLogo.setImageResource(0);
holder.ivBuilderLogo.setScaleType(ImageView.ScaleType.FIT_XY);
return false;
}
})
.into(holder.ivBuilderLogo);
My geçiş çekilebilir (R.drawable.anim_image_placeholder):
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/loading_frame1" android:duration="100" />
<!--<item android:drawable="@drawable/loading_frame2" android:duration="100" />-->
<item android:drawable="@drawable/loading_frame3" android:duration="100" />
<!--<item android:drawable="@drawable/loading_frame4" android:duration="100" />-->
<item android:drawable="@drawable/loading_frame5" android:duration="100" />
<!--<item android:drawable="@drawable/loading_frame6" android:duration="100" />-->
<item android:drawable="@drawable/loading_frame7" android:duration="100" />
<!--<item android:drawable="@drawable/loading_frame8" android:duration="100" />-->
<item android:drawable="@drawable/loading_frame9" android:duration="100" />
<!--<item android:drawable="@drawable/loading_frame10" android:duration="100" />-->
</animation-list>
(statik bir resim kullanılarak ise gerekli değildir)
hangi kütüphane Glide/İyon dan ... İkisini de kullanıyorum, Glide yük gif çok yavaş iken İyon yükleme 2x zaman glide kütüphanesinden daha hızlıdır.Ama görüntü kalitesi bakımından Glide İyondan daha iyidir .... Önerinizde @Dinesh ... –