fahrul avatar

Basic implementation android glide library

fahrulhidayat

Published: 19 Dec 2017 › Updated: 19 Dec 2017Basic implementation android glide library

Basic implementation android glide library

cover.jpg

Hello steemian, this time i want to discuss one of the popular android library for downloading and catching named glide,I like this library, it’s fast and efficient open source media management and image loading framework for android.
If you create android apps, of course there will always be the possibility of using images in app content, so in my opinion this will be useful for you

How to use it ?

Integrating Glide in your project is very easy. First add the glide dependency to your build.gradle.
dependencies {
// glide
compile 'com.github.bumptech.glide:glide:3.7.0'
}

borobudur.jpg

Previously I have prepared the image to be used, the image url to be used is
'codedojo.asia/images/tutorial_glide/borobudur.jpg'
by the way do you know the contents of the image that i use in this example? it is a picture of borobudur, a 9th-century Mahayana Buddhist temple in Magelang, Central Java, Indonesia, and the world's largest Buddhist temple.
Ok, back to tutorial, In this occasion i will guide you to use it in android studio project
First creating new project
a. Give the application name TutorialGlide (or whatever name you want)
b. Select minimum SDK 16 or more
the following is a guide to the example of a glide implementation

Step 1 . Create application name(in application name must begin with a capital letter)

tg1.PNG

Step 2 Choose minimum SDK
In determining the sdk used we must see from the number of users as well as the minimum sdk version of the version of libary glide that we use.

tg2.PNG

Step 3 Choose Empty Activity
Android studio already provides some main template that we can use, like drawer, map, admob etc, but for now we only use Empty activity.
tg3.PNG

Step 4 set name main activity and main layout then wait until the process finish.

tg4.PNG

Add gradle for glide into app/build.gradle, after we added it dont forget to klik sync now on the top right of the screen

useglide.PNG

Add internet permission in manifest, of course this permission is required because we take pictures from the server, if the image you want to use is taken from the drawable folder, this permission is not required

manifest.PNG

Adding view in layout to show image, do not forget to add id to imageView, because id is needed when we initialize ImageView in MainActivity so that glide can recognize which view will be given image

layoutimage.PNG

Write some code for initialize ImageView and loading image from url into imageView in Main Activity

mainactivitycode.PNG

Now we can run this application on mobile or in emulator, do not forget internet connection because picture we take from server,

result of screenshot in my handphone

Screenshot_2017-12-19-23-29-36.jpg

if you want to change the image to a size of 200px wide and 200px height and crop it in the center you can use this script :
glideresize.PNG

output after using resize script ini glide

Screenshot_2017-12-19-23-36-21.jpg

Conclusion

For the needs of the image process using glide is very easy, even google recommends the use of glide and use it in their internal project. besides using glide, for loading image we can also use other alternative that is picasso. if made a comparison between picasso and glide, each has advantages and disadvantages. For custom glides such as circular images, gallery creation and image content implementation using adapters we can discuss in the next post.



Posted on Utopian.io - Rewarding Open Source Contributors

Leave Basic implementation android glide library to:

Written by

Think like a rocket scientist

Read more #utopian-io posts


Best Posts From fahrul

We have not curated any of fahrulhidayat's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From fahrul