如何用glide、coil来显示图像(位图)

问题描述 投票:0回答:1

我想将图片插入可组合的 GlideImage 或 CoilImage 或 Image 中。我根据资源/可绘制(image.jpg)或移动画廊(Uri)的条件获取图片。对于 Image(){},我将图像解码为位图。如何使用位图进行滑行和线圈?

android android-jetpack-compose android-glide coil
1个回答
0
投票

试试这个:

    AsyncImage(
        model = ImageRequest
            .Builder(context)
            .data(Uri)
            .crossfade(true)
            .build(),
        contentDescription = null,
        modifier = Modifier
            .size(100.dp, 60.dp)
        contentScale = ContentScale.Crop,
        error = painterResource(id = R.drawable.ic_error),
        placeholder = painterResource(id = R.drawable.ic_ placeholder)
    )

希望这可以帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.