Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
forked fromcoil-kt/coil

Image loading for Android backed by Kotlin Coroutines.

License

NotificationsYou must be signed in to change notification settings

yschimke/coil

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Coil

An image loading library for Android backed by Kotlin Coroutines. Coil is:

  • Fast: Coil performs a number of optimizations including memory and disk caching, downsampling the image in memory, automatically pausing/cancelling requests, and more.
  • Lightweight: Coil adds ~2000 methods to your APK (for apps that already use OkHttp and Coroutines), which is comparable to Picasso and significantly less than Glide and Fresco.
  • Easy to use: Coil's API leverages Kotlin's language features for simplicity and minimal boilerplate.
  • Modern: Coil is Kotlin-first and uses modern libraries including Coroutines, OkHttp, Okio, and AndroidX Lifecycles.

Coil is an acronym for:CoroutineImageLoader.

Translations:日本語,한국어,Русский,Svenska,Türkçe,中文

Download

Coil is available onmavenCentral().

implementation("io.coil-kt:coil:2.6.0")

Quick Start

ImageViews

To load an image into anImageView, use theload extension function:

// URLimageView.load("https://example.com/image.jpg")// FileimageView.load(File("/path/to/image.jpg"))// And more...

Requests can be configured with an optional trailing lambda:

imageView.load("https://example.com/image.jpg") {    crossfade(true)    placeholder(R.drawable.image)    transformations(CircleCropTransformation())}

Jetpack Compose

Import theJetpack Compose extension library:

implementation("io.coil-kt:coil-compose:2.6.0")

To load an image, use theAsyncImage composable:

AsyncImage(    model="https://example.com/image.jpg",    contentDescription=null,)

Image Loaders

BothimageView.load andAsyncImage use the singletonImageLoader to execute image requests. The singletonImageLoader can be accessed using aContext extension function:

val imageLoader= context.imageLoader

ImageLoaders are designed to be shareable and are most efficient when you create a single instance and share it throughout your app. That said, you can also create your ownImageLoader instance(s):

val imageLoader=ImageLoader(context)

If you do not want the singletonImageLoader, depend onio.coil-kt:coil-base instead ofio.coil-kt:coil.

Requests

To load an image into a custom target,enqueue anImageRequest:

val request=ImageRequest.Builder(context)    .data("https://example.com/image.jpg")    .target { drawable->// Handle the result.    }    .build()val disposable= imageLoader.enqueue(request)

To load an image imperatively,execute anImageRequest:

val request=ImageRequest.Builder(context)    .data("https://example.com/image.jpg")    .build()val drawable= imageLoader.execute(request).drawable

Check out Coil'sfull documentation here.

R8 / Proguard

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 forCoroutines andOkHttp.

License

Copyright 2023 Coil ContributorsLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.

About

Image loading for Android backed by Kotlin Coroutines.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin99.8%
  • Other0.2%

[8]ページ先頭

©2009-2025 Movatter.jp