我希望以下代码可以对您有所帮助
private void LoadBackground(){
    ParseFile f = messageObject.getParseFile("image");
    voiceFile = messageObject.getParseFile("");
    if( f == null) return;
    String fpath = f.getUrl().toString();
    if(f.getUrl() == null) return;
    if (!fpath.equalsIgnoreCase("")) {
        if (!fpath.startsWith("http://") && !fpath.startsWith("https://")) {
            Log.d("refreshProfile",fpath);
            File imgFile = new File(fpath);
            Bitmap bitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
            if (bitmap != null) {
                imgBg.setImageBitmap(bitmap);
            }
        } else {
            ImageLoader.getInstance().displayImage(fpath, imgBg,
                DisplayImageOption.getDisplayImage(),
                new AnimateFirstDisplayListener(){
                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                        pbLoading.setVisibility(View.GONE);
                    }
                });
        }
    }
}
以下是监听器的代码
public class AnimateFirstDisplayListener extends SimpleImageLoadingListener {
  public static final List<String> displayedImages = Collections.synchronizedList(new LinkedList<String>());
     @Override
     public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
       if (loadedImage != null) {
           ImageView imageView = (ImageView) view;
           boolean firstDisplay = !displayedImages.contains(imageUri);
           if (firstDisplay) {
               FadeInBitmapDisplayer.animate(imageView, 500);
               displayedImages.add(imageUri);
           }
       }
   }
}
显示图像选项.java
public class DisplayImageOption {
   public static DisplayImageOptions getDisplayImage() {
       DisplayImageOptions options = new DisplayImageOptions.Builder()
       .showImageOnLoading(R.drawable.background)
       .showImageForEmptyUri(R.drawable.background)
       .showImageOnFail(R.drawable.background)
       .cacheInMemory(true)
       .cacheOnDisk(true)
       .considerExifParams(true)
       .build();
       return options;
   }
   public static DisplayImageOptions getDisplayRoundedImage() {
       DisplayImageOptions options = new DisplayImageOptions.Builder()
       .showImageOnLoading(R.drawable.ic_launcher)
       .showImageForEmptyUri(R.drawable.ic_launcher)
       .showImageOnFail(R.drawable.ic_launcher)
       .cacheInMemory(true)
       .cacheOnDisk(true)
       .considerExifParams(true)
       .displayer(new RoundedBitmapDisplayer(100))
       .build();
       return options;
   }
}