How to use a drawable resource as a background color?

Viewed 109

I have a drawable resource and I want to use it as a background color for my lazy column items.

Code:

    @Composable
fun HabitItem(
    habit: Habit,
    onDeleteClick: () -> Unit,
    navController: NavHostController
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .padding(8.dp)
             .background(//I want to place the drawable resource here)
    ) {

Any help?

Note: The purpose of using drawable resource instead of a color is that I want to add corner radius to the items. So if there is a way to add a corner radius without drawable that will work as well.

1 Answers

For corner radius just use:

    Modifier.clip(shape = RoundedCornerShape(8.dp))
            .background(color)

Do the clipping before the background.

More here.

Related