简体   繁体   中英

Adding image to scaffold top bar in jetpack compose

I'm trying to add an image from a database to my top bar but it shows up as a white filled in rectangle - the image doesn't show at all. here's the below code. the way I have the icon set up works elsewhere in my app, it's just in this top bar for the scaffold it doesn't work. any insights?

TopBar.kt

    TopAppBar (
        title = {
            Row(
                modifier = Modifier.fillMaxWidth(),
                verticalAlignment = Alignment.CenterVertically
            ) {
                Text(
                    text = "Test
                )
                Row(
                    modifier = Modifier.fillMaxWidth(),
                    horizontalArrangement = Arrangement.End
                ) {
                    Icon(
                        painter = rememberAsyncImagePainter(test.firstImage),
                        contentDescription = "Image")
                }
            }
        }
    )
Class.kt

 Scaffold(topBar = {TopBar()}) { innerPadding ->
        Column(modifier = Modifier

The Icon applies a default tint.
Use tint= Color.Unspecified to avoid it:

Icon(
    painter = rememberAsyncImagePainter(test.firstImage),
    contentDescription = "Image",
    tint = Color.Unspecified
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM