Android Compose GlideImage

2024. 4. 23. 14:00Android

반응형

Android Compose 를 사용도중

 

Glide가 필요해 Compose에서 Glide 사용법에 대해 알아보겠습니다.

 

GlideImage git

https://github.com/skydoves/landscapist

 

GitHub - skydoves/landscapist: 🌻 A pluggable, highly optimized Jetpack Compose and Kotlin Multiplatform image loading library

🌻 A pluggable, highly optimized Jetpack Compose and Kotlin Multiplatform image loading library that fetches and displays network images with Glide, Coil, and Fresco. - skydoves/landscapist

github.com

 

build.gradle

implementation "com.github.skydoves:landscapist-glide:2.3.3"

 

kotlin

GlideImage(
    imageModel = { "여기에 url" },
    imageOptions = ImageOptions(
        contentScale = ContentScale.Crop,
        alignment = Alignment.Center
    )
)

 

 

아주 간단하게 표현 할수있다

 

추가적으로 GlideImage 에서 자체적으로 modifier 도 지원을 한다

 

GlideImage(
    imageModel = { "https://m.kt.com/images/area/A000000061/C000010858v2481h46332.jpg" },
    imageOptions = ImageOptions(
        contentScale = ContentScale.Crop,
        alignment = Alignment.Center
    ),
    modifier = Modifier.fillMaxWidth().heightIn(max=200.dp)
)

 

해당 코드를 응용해  실제 적용한 모습

 

해당 코드

 

Card(
    shape = RoundedCornerShape(topEnd = 20.dp , topStart = 20.dp)
) {
    GlideImage(
        imageModel = { "https://m.kt.com/images/area/A000000061/C000010858v2481h46332.jpg" },
        imageOptions = ImageOptions(
            contentScale = ContentScale.Crop,
            alignment = Alignment.Center
        ),
        modifier = Modifier.fillMaxWidth().heightIn(max=200.dp)
    )
}

 

감사합니다.

반응형

'Android' 카테고리의 다른 글

Android Compose LazyColumn (RecyclerView 대체)  (0) 2024.04.25
Android Compose Row , Column , Box 살펴보기  (0) 2024.04.25
Android NDK 란?  (0) 2022.08.08
Android Compose 적용 해보기 2  (0) 2022.07.05
Android Compose 적용 해보기 1  (0) 2022.06.24