Icon
可在内部绘制
IconButton
composable是黑色的,尽管它是白色的。下图显示了当前设置的右上角的垃圾桶图标
alpha
@Composable
fun AppImage(
modifier: Modifier = Modifier,
imageUri: Uri = Uri.EMPTY,
contentScale: ContentScale = ContentScale.None,
contentDescription: String? = null,
loadingImage: @Composable (SubcomposeAsyncImageScope.(AsyncImagePainter.State.Loading) -> Unit)? = null,
successResult: @Composable (SubcomposeAsyncImageScope.(AsyncImagePainter.State.Success) -> Unit)? = null,
errorResult: @Composable (SubcomposeAsyncImageScope.(AsyncImagePainter.State.Error) -> Unit)? = null
) {
Card(
modifier = Modifier
.height(250.dp)
.width(350.dp)
.padding(15.dp)
.clickable(
indication = null,
interactionSource = remember { MutableInteractionSource() }) {
},
elevation = 7.dp
) {
Box(
modifier = Modifier
.padding(16.dp)
.wrapContentSize(Alignment.Center)
) {
SubcomposeAsyncImage(
model = imageUri,
modifier = modifier,
contentScale = contentScale,
contentDescription = contentDescription,
loading = loadingImage,
success = successResult,
error = errorResult
)
IconButton(
onClick = {},
modifier = Modifier
.clip(CircleShape)
.background(color = Color.Black.copy(alpha = 0.5f))
.align(Alignment.TopEnd)
.size(33.dp)
) {
Icon(
painterResource(id = R.drawable.ic_filled_delete_30),
contentDescription = "Delete Item Picture",
modifier = Modifier
.clickable(onClick = {
})
)
}
}
}
}