如何滚动JetPack组合屏幕溢出其内容?

发布于 2025-02-11 00:03:57 字数 96 浏览 2 评论 0原文

我有一个添加的购物清单项目JetPack组成的屏幕,其中包含几个Textfield输入和一个位于底部的图像容器。屏幕在底部溢出并切断。如何滚动屏幕?

I have an Add Shopping List item Jetpack Compose screen which contains several TextField inputs and an image container at the bottom. The screen overflows at the bottom and is cut off. How can I scroll the screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凌乱心跳 2025-02-18 00:03:58

编辑:2023年10月

在此过程中的某个时候,旧解决方案不再起作用。现在解决这个问题的解决方案是:

val scrollState = rememberScrollState()
...
Column( // or whatever your parent composable is
    modifier = Modifier
        .verticalScroll(state = scrollState)
) {
    ...
}

旧解决方案

添加修改器。可滚动(..)到您希望制作可滚动的容器。
代码将是这样的:

val scrollState = rememberScrollState()
...
Box( // or whatever your parent composable is
    modifier = Modifier
        .scrollable(state = scrollState, orientation = Orientation.Vertical)
) {
    ...
}

当然,还有其他修饰符用于使组合滚动的方法可能更适合您的情况。

EDIT: October 2023

At some point along the way this was changed and the old solution does not work anymore. The solution to this question is now:

val scrollState = rememberScrollState()
...
Column( // or whatever your parent composable is
    modifier = Modifier
        .verticalScroll(state = scrollState)
) {
    ...
}

Old solution

Add Modifier.scrollable(..) to the container that you wish to make scrollable.
Code would be something like this:

val scrollState = rememberScrollState()
...
Box( // or whatever your parent composable is
    modifier = Modifier
        .scrollable(state = scrollState, orientation = Orientation.Vertical)
) {
    ...
}

Of course, there are other Modifier methods for making composables scrollable that might fit better for your case.

去了角落 2025-02-18 00:03:58

如果批准的答案不起作用,请尝试下面的尝试,

val scrollState = rememberScrollState()

Column(
    modifier = Modifier.verticalScroll(state = scrollState)
) { 
    ...
}

请不要忘记将其应用于您的父母合并

If the approved answer is not working try like below

val scrollState = rememberScrollState()

Column(
    modifier = Modifier.verticalScroll(state = scrollState)
) { 
    ...
}

Do not forget to apply it to your parent composable

懒猫 2025-02-18 00:03:58

您可以在容器上使用修饰符垂直旋转实现此目的。

Column(
  modifier = Modifier.verticalScroll(state = rememberScrollState())
) { 
  ...
}

You can use the modifier verticalScroll on your container to achieve this.

Column(
  modifier = Modifier.verticalScroll(state = rememberScrollState())
) { 
  ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文