Search code examples
androidxmlfresco

use xml file in simpleimageview setplaceholderimage


Is there any way to use xml layout into fresco library instead of hierarchy image? I used layout like below :

simpledraweeview.getHierarchy().setPlaceholderImage(layout.id);

but it didn't work.

this error hapend :

.Resources$NotFoundException: File res/layout/hierarchy_layout.xml from drawable resource ID #0x7f040049


Solution

  • It means the resource what you are trying to apply is not available. My Suggestion is you can try Picasso library.

    Picasso.with(context)
    .load(url)
    .placeholder(R.drawable.user_placeholder)
    .error(R.drawable.user_placeholder_error)
    .into(imageView);
    

    or you can try Glide library.

    Glide.with(myFragment)
        .load(url)
        .centerCrop()
        .placeholder(R.drawable.loading_spinner)
        .crossFade()
        .into(myImageView);