https://kotlinlang.org logo
#compose
Title
# compose
a

Android75

04/03/2022, 5:24 AM
I don’ t understand why i can’t have a card with image that filled all card.
Copy code
Column(modifier = Modifier.fillMaxSize().padding(10.dp)) {
    WPToolBar("Grid", textColor = Color.Blue, showBack = true)
    Spacer16()
    Row(
        modifier = Modifier.fillMaxWidth().weight(1f)) {
        Box(modifier = Modifier.weight(1f).fillMaxHeight()) {
            CardCell()
        }

        Box(modifier = Modifier.weight(1f).fillMaxHeight()) {
            CardCell()
        }
    }
    
    Row(
        modifier = Modifier.fillMaxWidth().weight(1f)) {
        Box(modifier = Modifier.weight(1f).fillMaxHeight()) {
            CardCell()
        }

        Box(modifier = Modifier.weight(1f).fillMaxHeight()) {
            CardCell()
        }
        
    }
}

@Composable
fun CardCell() {
    Card(elevation = 4.dp,  shape = RoundedCornerShape(20.dp) ,modifier = Modifier.fillMaxSize().padding(10.dp)) {
            Image(
                contentScale = ContentScale.Fit,
                contentDescription = null,
                painter = painterResource(id = R.drawable.preview2)

            )
        }
}
n

nuhkoca

04/03/2022, 5:31 AM
Can you pass
FillWidth
or
Crop
for the
contentScale
?
a

Android75

04/03/2022, 5:33 AM
great , thanks
n

nuhkoca

04/03/2022, 5:34 AM
did it work?
a

Android75

04/03/2022, 5:34 AM
yes
👍🏻 1
👍 1
perfect.. online … i didn’t see contentScale in all example
n

nuhkoca

04/03/2022, 5:36 AM
yes there are not that much samples on the Internet as Compose is not mature yet I guess 🙂
c

Chris Sinco [G]

04/04/2022, 12:01 AM
Always know you can navigate to the definition of the Composable in Android Studio with Cmd/Ctrl+B. It's a very useful way to see all the parameters a component supports, e.g. contentScale
1