A preliminary study on Android Glide picture loading frame

Source: Internet
Author: User

I. Introduction to the glide picture loading framework

Google 2014 Developer Forum on the introduction of the picture loading framework, it allows us to deal with whether it is a network download pictures or local pictures, reduce a lot of work,

Second, the development steps:

1. Add a link library

Compile ' com.github.bumptech.glide:glide:3.7.0 '

2, code writing, the main features

Glide.with (context).                Load (imgurl)                . Dontanimate ().                Skipmemorycache (True)                . Diskcachestrategy ( Diskcachestrategy.all)                . Placeholder (r.drawable.head_default).                error (R.drawable.head_default). into                (ImageView);

When loading a picture on the network, Imgurl: The address of the picture

When a local picture is loaded

Glide.with (context)               //. Load (Imgurl)                . Load (Uri.fromfile (new File (Imgurl)))

"When loading pictures on the network, due to network reasons, the picture is not displayed in time, need to display a waiting picture

. Placeholder (R.drawable.head_default)

When a picture fails to load for various reasons, the picture is displayed

. Error (R.drawable.head_default)

"Sets the animation for picture loading

. Dontanimate ()//Set the picture to load directly, do not display the animation                . Crossfade ()//settings load picture for fade in

"To set how the image is scaled

  . Centercrop ()  . Fitcenter ()

Note:

. Centercrop () to fit the picture to the size of the view
. Fitcenter () Trim zoom, so that the size of the picture is less than the size of the view, it is possible to account for the size of the view
"Sets the cache for the picture


. Skipmemorycache (True)//Skip Memory Cache

  . diskcachestrategy( diskcachestrategy. NONE ) //Skip HDD cache

    • DiskCacheStrategy.NONEDon't cache anything.
    • DiskCacheStrategy.SOURCEJust cache the original full-resolution image
    • DiskCacheStrategy.RESULTOnly the final image is cached, that is, after the resolution is lowered (or converted)
    • DiskCacheStrategy.ALLCache all versions of images ( default behavior )

"Sets the priority for picture loading

. Priority (Priority.high) Priority.LOWPriority.NORMALPriority.HIGHPriority.IMMEDIATE   

"Loading GIF animations

. Asgif ()//Determine if the loaded URL resource is a GIF-formatted resource

"Show pictures

. into (ImageView);

  

A preliminary study on Android Glide picture loading frame

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.