coil-kt / coil
- понедельник, 16 сентября 2019 г. в 00:24:08
Kotlin
Image loading for Android backed by Kotlin Coroutines.
An image loading library for Android backed by Kotlin Coroutines. Coil is:
Coil is an acronym for: Coroutine Image Loader.
Made with
Coil is available on mavenCentral().
implementation("io.coil-kt:coil:0.7.0")To load an image into an ImageView, use the load extension function:
// URL
imageView.load("https://www.example.com/image.jpg")
// Resource
imageView.load(R.drawable.image)
// File
imageView.load(File("/path/to/image.jpg"))
// And more...Requests can be configured with an optional trailing lambda:
imageView.load("https://www.example.com/image.jpg") {
crossfade(true)
placeholder(R.drawable.image)
transformations(CircleCropTransformation())
}To get an image imperatively, use the get suspend function:
val drawable = Coil.get("https://www.example.com/image.jpg")Coil requires Java 8 bytecode. Here's how to enable it.
Check out Coil's full documentation here.
Coil is fully compatible with R8 out of the box and doesn't require adding any extra rules.
If you use Proguard, you may need to add rules for Coroutines, OkHttp and Okio.
Copyright 2019 Coil Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.