这篇文章是这个系列的最后一篇,前面一篇讲到如何使用CameraX对预览照片进行截图,这篇文章会在上一篇代码的基础上,来分享下如何从图库中选中一张照片,上篇文章中有下面这段代码:
val emptyImageUri = Uri.parse("file://dev/null")
Image(
modifier = Modifier.fillMaxSize(),
painter = rememberAsyncImagePainter(imageUri),
contentDescription = "Captured image"
)val emptyImageUri = Uri.parse("file://dev/null")
Image(
modifier = Modifier.fillMaxSize(),
painter = rememberAsyncImagePainter(imageUri),
contentDescription = "Captured image"
)
所以如果要显示图片,我们只要从图库中选中一张图片,然后转换成URI的形式就可以。
Hello Yu