Android Universal-imageloader displayimageoptions Detailed configuration

Source: Internet
Author: User

When using this framework, we have to configure a Displayimageoptions object to act as a parameter in the Imageloader.getinstance (). DisplayImage (), so it is necessary to explain how this object is formulated. After the explanation, we will know more about this framework.


1. Default configuration



Displayimageoptions options =NewDisplayimageoptions.builder (). showimageonloading (R.drawable.ic_stub)//resource or drawable. Showimageforemptyuri (R.drawable.ic_empty)//resource or drawable. Showimageonfail (R.drawable.ic_error)//resource or drawable. resetviewbeforeloading (false)//default. Delaybeforeloading (Cacheinmemory) (false)//default. Cacheondisk (false)//default. Preprocessor (...)    . Postprocessor (...)    . Extrafordownloader (...) . Considerexifparams (false)//default. Imagescaletype (Imagescaletype.in_sample_power_of_2)//default. Bitmapconfig (Bitmap.Config.ARGB_8888)//default. Decodingoptions (...) . Displayer (NewSimplebitmapdisplayer ())//default. Handler (NewHandler ())//default. build ();



Example



    /*** Show all configurations of pictures *@return     */    PrivateDisplayimageoptions getwholeoptions () {displayimageoptions options =NewDisplayimageoptions.builder (). showimageonloading (r.drawable.loading)//set the picture that the picture displays during the download. Showimageforemptyuri (R.drawable.ic_launcher)//sets the picture to be displayed when the image URI is empty or wrong. Showimageonfail (R.drawable.error)//set picture to display when errors are displayed during image load/decode. Cacheinmemory (true)//sets whether the downloaded picture is slow to exist in memory. Cacheondisk (true)//sets whether the downloaded picture is slow to exist on the SD card. Considerexifparams (true)//whether to consider the JPEG image exif parameter (rotate, flip). Imagescaletype (Imagescaletype.in_sample_int)//set how images are displayed in an encoded manner. Bitmapconfig (Bitmap.Config.RGB_565)//set the decoding type of a picture//. Decodingoptions (bitmapfactory.options decodingoptions)//set the decoding configuration for a picture. delaybeforeloading (0)//int Delayinmillis The delay before the download is set for you//Set up bitmap before adding a picture to the cache//. Preprocessor (bitmapprocessor preprocessor). resetviewbeforeloading (true)//set whether the picture is reset before downloading, reset. Displayer (NewRoundedbitmapdisplayer (20))//NOT recommended!!! is set to fillet, how many radians. Displayer (NewFadeinbitmapdisplayer (100))//if the picture is loaded and the animation time fades in, it may appear flashing. build ();//Build Complete                returnOptions }



2. General-Use configurations



        /*** Set Common settings items *@return     */    PrivateDisplayimageoptions getsimpleoptions () {displayimageoptions options =NewDisplayimageoptions.builder (). showimageonloading (r.drawable.loading)//set the picture that the picture displays during the download. Showimageforemptyuri (R.drawable.ic_launcher)//sets the picture to be displayed when the image URI is empty or wrong. Showimageonfail (R.drawable.error)//set picture to display when errors are displayed during image load/decode. Cacheinmemory (true)//sets whether the downloaded picture is slow to exist in memory. Cacheondisk (true)//sets whether the downloaded picture is slow to exist on the SD card. Imagescaletype (Imagescaletype.in_sample_int)//set how images are displayed in an encoded manner. Bitmapconfig (Bitmap.Config.RGB_565)//set the decoding type of a picture. build ();//Build Complete        returnOptions }



Note: This parameter of course can also be arbitrarily modified, according to the project needs to be determined!



A few notes:


1). Imagescaletype (Imagescaletype imagescaletype)//Set How the image is scaled, such as:


. Imagescaletype (Imagescaletype.in_sample_int)

Among them, the selection value of Magescaletype:
Exactly: the target size at which the image will be fully scaled
Exactly_stretched: The picture zooms to the target size completely
In_sample_int: The image will be sampled in multiples of two times
In_sample_power_of_2: The picture will be lowered twice times until the next reduction step to make the image smaller target size
NONE: Picture does not adjust


2). Displayer (Bitmapdisplayer displayer)//Set How the picture is displayed, such as:


. Displayer (New Fadeinbitmapdisplayer (100))

Among them, the selection value of Displayer:


Roundedbitmapdisplayer (int roundpixels) set fillet picture, not recommended!!!
Fakebitmapdisplayer () This class didn't do anything.
Fadeinbitmapdisplayer (int durationmillis) time to set the picture fade
Simplebitmapdisplayer () normal display of a picture



3. Avoid Oom


. Bitmapconfig (Bitmap.Config.RGB_565) ///default is argb_8888, using rgb_565 will consume twice times less than argb_8888


Using. Imagescaletype (imagescaletype.in_sample_int) or imagescaletype (imagescaletype.exactly)


Avoid using . Displayer (new Roundedbitmapdisplayer) // He will create a new bitmap object in the argb_8888 format;


Android Universal-imageloader displayimageoptions Detailed configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.