Reputation: 119
I am trying to place a card on top of a map view. And I want the card to locate close to the bottom.
I used a box layout and put the map and card into it. But I only know contentAlignment to arrange the inside components. Now I have the card dispalyed above the map centrally. How can I fix it? What kind of layout setup is required?
what I want
what I get
My code.
Box(
contentAlignment = Alignment.Center
) {
MapScreen()
Card(
modifier = Modifier
.width(380.dp)
.height(350.dp),
elevation = 10.dp,
shape = RoundedCornerShape(15.dp)
)
{
Column(
Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
)
{
Spacer(modifier = Modifier.height(10.dp))
Recomendationm(indicatorValue = value)
Text("Here")
}
}
}
Upvotes: 1
Views: 4370
Reputation: 363825
In your Card
you can use the align
modifier to override the contentAlignment
defined by the parent Box
:
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
//..
Card(
modifier = Modifier
.width(380.dp)
.height(350.dp)
.align(BottomCenter),
//...
}
As described in the doc:
Pull the content element to a specific
Alignment
within theBox
. This alignment will have priority over theBox
'salignment
parameter.
Upvotes: 1