FinalBitmap in Afianl frame loads network images

  • 2020-06-23 01:58:23
  • OfStack

FinalBitmap in Afinal: Used to display bitmap images without concerns about thread concurrency and oom.

1. Test the request

Using web page open http: / / avatar csdn. net C / 6/8/1 _bz419927089. jpg "can see picture 1.

2. Create the FinalBitmap object


  FinalBitmap bitmap = FinalBitmap.create(this);

3. Set the uri address of the image


  String uri = "http://avatar.csdn.net/C/6/8/1_bz419927089.jpg";

4. Load pictures


   private ImageView iv;

   iv=(ImageView)findViewById(R.id.imageView);

  // Initializes the image that is displayed when loaded 

  Bitmap loadingBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.snapshotmg);/*R.drawable.snapshotmg Displays the image by default */

  // Initialization failed to load the image displayed 

  Bitmap failBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.snapshotmg);

  // The first 1 Kind of way: image For the control to display an image 
  bitmap.display(iv, uri);
  // The first 2 Kind of way: loadingBitmap Is the image displayed while loading 
  //bitmap.display(iv, uri, loadingBitmap);
  // The first 3 Kind of way: loadingBitmap Is the image in load, failBitmap Failed to load the image 
  // bitmap.display(iv, uri, loadingBitmap, failBitmap);
  // The first 4 Way: We can also set the size of the loaded image 
  //bitmap.display(iv, uri, 100, 100);
  // The first 5 How to do this: Set the size of the loaded image as well as load and fail images 
  //bitmap.display(iv, uri, 100, 100, loadingBitmap, failBitmap);

This is the end of this article, I hope you enjoy it.


Related articles: