Android: How to use TextView in placeholder of Glide or Picasso - android

i am using Glide or Picasso for loading the image like
Glide.with(context).load(POST_IMAGE).placeholder(R.drawable.loading_img).error(R.drawable.bg_480_800).into(image);
Picasso.with(context).load("image url").error(R.drawable.bg_480_800).placeholder(R.drawable.loading_img).into(holder.imageURL);
In these two, i'm using image as place holder from the drawable folder. Now i want to use text inside the place holder instead of image from drawable folder.
So, please help me to load text instead of loading image from the drawable folder

Placeholder is a Drawable, so what you'll need is some kind of Drawable that is able to display text. This library does exactly that, and does it pretty well.

Related

how to load xml in imageview using glide

I have created an gradient xml in drawable folder of my project. I want to load that xml in an ImageView using Glide. How can I do that ?
Simple loading of image in ImageView using Glide:
Glide.with(LoginActivity.this).load(R.drawable.a270).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);
But if I use the same code above replacing R.drawable.a270 with R.drawable.gradient_background with a drawable xml its not working.
Please try this -
Glide.with(LoginActivity.this).load("").error(R.drawable.gradient_background).diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);
OR
Glide.with(LoginActivity.this).load(null).fallback(R.drawable.gradient_background).diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);
I doubt you are using VectorDrawable or animated drawable. Please refer this and this for more information on this.

Load dyanmic resource drawable using Picasso

I want to load multiple drawable-resources in RecyclerView and i am using Picasso in RecyclerView.ViewHolder for this task.
Picasso.with(context)
.load(imageList.get(position))
.into(imageView);
Picasso loads the drawable-resources which are in drawable folder but it doesn't load resources from other drawable.
For example if i put the drawables in all drawable folders(mdpi,hdpi,xhdpi etc) except "drawable" folder, It doesn't work.
So is there something I am missing? is it possible to dynamic reference to the drawables using Picasso?
Picasso should load mipmaps. Try forcing just one to show, like
Picasso.with(context).load(R.mipmap.ic_launcher).into(imageView);
and see if is loading. If it is, there is something with your id's from array.

How to show dynamic drawable using Picasso

I have some drawable generated dynamically from material design icons
Drawable qq = new IconDrawable(context, FontAwesomeIcons.fa_qq).
colorRes(R.color.qq).sizeRes(R.dimen.button_height_normal);
I want to show this Drawable using Picasso but when try to load this Drawable get an error because Picasso load accept only url for the Drawable and I can't get it or get it's Resource Id.
there any way to make that ?
I've made a workaround as I've not seen the way to set directly a dynamically generated drawable. Picasso has the "error" and "placeholder" options that they both allow inputing a drawable so if you make the load to fail the Picasso will load the drawable (with you desired transformations, for instance):
Picasso.with(context).load("nothing").error(placeholder).placeholder(placeholder).into(this)
where placeholder is the drawable you want to load

Picasso PlaceHolder Image : OutOfMemory

I am working with Android Picasso Library and after setting image from drawable folder in placeholder,I am getting outOfMemory exception. Do picasso place holder image stays in memory, If yes then how to remove placeHolder image when actual image is loaded?
This happens because system try to Scale it according to density of the device .The solution worked for me is to create a folder named drawable-nodpi inside your res folder . Then put your placeholder image into that folder .
Let me know if it works .
You may try resizing your placeholder image since it might be to big and causing OutOfMemory, but it can be also more complex error not only of placeholder. And maybe it's not the problem of placeholder but of current image loaded from url which is too big? You can resize this image with below code:
picasso.with(mContext)
.load(someUrl)
.resize(sizeX, sizeY)
.placeHolder(R.drawable.placeholder)
.into(imageView);

How can I set Picasso placeholder scaleType?

I've problem with placeholder images in Picasso. I use scaleType fitXY on one of my imageViews, but I don't really wanna scale my placeholder, is there a way that I can set different scaleType for my placeholder and another one for loaded image?
Use Fresco lib open source library by Facebook, Using this library You can set different scale type to placeholder image and actual image use this link for reference http://frescolib.org/

Categories

Resources