Nefario
Nefario

Reputation: 31

Jetpack Compose first argument modifier doesn't work

I'm learning Compose and I just wanted to style my item for my LazyColumn. However when I'm adding the first argument it seems to always reject it. Even when I delete the padding, the next argument will be in err.

Can anyone see something I'm missing because I've been looking at this for an hour.

@Composable
fun NewsArticleItem(news: News) {
    Row {
        Column(
            modifier = Modifier
                .padding(16.dp)
                .background(Color.Green)
                .fillMaxWidth()
                .align(Alignment.CenterVertically)
        ) {
            Text(text = news.title, style = typography.h5)
            Text(text = news.body, style = typography.caption)
        }
    }
}

Upvotes: 1

Views: 879

Answers (1)

Phil Dukhov
Phil Dukhov

Reputation: 87605

You can't pass dp into .fillMaxWidth() You can pass 0..1 Float there, which will make it take part of available width, default is 1

You can specify dp into .width(56.dp) modifier

If this didn't help, please specify which modifier exactly doesn't work in your case? Width fixed width modifier in my case everything seems work as expected

Upvotes: 1

Related Questions