简体   繁体   English

Jetpack Compose:带分数的可滚动列

[英]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.

相关问题 Jetpack Compose 中的延迟滚动 - Lazy Scrollable in Jetpack Compose Jetpack Compose:如何将 LazyVerticalGrid 放入可滚动列中? - Jetpack Compose: How to put a LazyVerticalGrid inside a scrollable Column? Jetpack Compose - 带有可滚动内容的框 - Jetpack Compose - Box with scrollable content 是否可以在jetpack compose测试中断言节点可滚动 - Is it possible to assert that a node is scrollable in jetpack compose testing 如何在 Jetpack Compose 中使文本可滚动 - How to make Text scrollable in Jetpack Compose Modifier.Scrollable 在 Android Jetpack Compose 中 - Modifier.Scrollable in Android Jetpack Compose 在 ConstraintLayout 中使用 Jetpack Compose 垂直滚动组件 - Use Jetpack Compose vertically scrollable component in ConstraintLayout 如何创建一个 Jetpack Compose Column,其中一个中间子项可滚动,但所有其他子项始终可见? - How do I create a Jetpack Compose Column where a middle child is scrollable but all of the other children are always visible? 避免意外点击/触摸 Jetpack Compose Slider,它位于可滚动列中 - Avoid accidental tap/touch in a Jetpack Compose Slider which is placed inside in a scrollable column VerticalScroll 在 Jetpack 撰写列中不起作用 - VerticalScroll is not working in the Jetpack compose column
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM