[英]Jetpack Compose : Scrollable column with fractions
I have 3 elements in a column.我在一列中有 3 个元素。
I want the 1st element to take 50% of screen and the remaining to take rest of space or scroll if needed.我希望第一个元素占据 50% 的屏幕,其余元素占据 rest 的空间或在需要时滚动。
I have tried the following:我尝试了以下方法:
Using verticallScroll() with fractions is not working.将 verticallScroll() 与分数一起使用是行不通的。 If i disable verticallScroll() then the 1st element takes 50% of the screen but the screen does not scrolls if needed.如果我禁用 verticallScroll(),则第一个元素占据屏幕的 50%,但如果需要,屏幕不会滚动。
Column( modifier = Modifier.background(color = Color.Black).padding(horizontal = 15.dp).verticalScroll(state = rememberScrollState(), enabled = true).fillMaxSize() ) { QuickTipsCard( modifier = Modifier.fillMaxWidth().fillMaxHeight(0.5f), backgroundColor = LightBlue, title = "Good morning,", description = "0 out of 10 task today". titleStyle = Typography.h1 )
} }
You can wrap the Column
in a BoxWithConstraints
component and use the maxHeight property to calculate the desired heights for the elements in the column.您可以将Column
包装在BoxWithConstraints
组件中,并使用 maxHeight 属性计算列中元素的所需高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.