简体   繁体   中英

How to load static image using Glide in android

Im using glide to presenting a banner in my application. Although it worked on URL string, but I want it to use static images instead.

I have a image test.jpg in /res/drawable . I tried replace the url string with /res/drawable/test.jpg but it wont work.

Here is the code:

 Glide.with(viewHolder.itemView)
                        .load("https://laz-img-cdn.alicdn.com/images/ims-web/TB1pHADjBr0gK0jSZFnXXbRRXXa.jpg_1200x1200.jpg")
                        .fitCenter()
                        .into(viewHolder.imageViewBackground);

I prefer using Coil Library because its new and simple to use. for you issue use this code

Glide.with(viewHolder.itemView)
        .load(R.drawable.test)
        .into(viewHolder.imageViewBackground)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM