Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot add Background color on Kotlin Jetpack Compose

I want to add a background color on my Floating Action Button but I cannot seem to add it. On older Yotuube videos adding a backgroundColor would make it possible but it seems that it is not possible to do it now. Any help?

@Composable
fun HomeView(){
    val context = LocalContext.current
    Scaffold(

        topBar = {AppBarView(title = "WishList",{
            Toast.makeText(context,"Button Clicked:",Toast.LENGTH_LONG).show()

        })},
        floatingActionButton = {
            FloatingActionButton(
                modifier = Modifier.padding(all = 20.dp),
                contentColor = Color.White,
                //I want to add a Background color here
                onClick = { //TODO Add Navigation to edit screen}) {
                
            }
        }
    ) {
        LazyColumn(modifier = Modifier
            .fillMaxSize()
            .padding(it)){

        }
    }
}```

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can use containerColor for it. In the docs it says

the color used for the background of this FAB. Use Color.Transparent to have no color.

If you don’t set it, the contentColor is used by default.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading