Compose Column 滑动起来

2021-09-04  本文已影响0人  菜鸟何时起飞
   val scrollState = rememberScrollState()
    Column(modifier = Modifier.fillMaxSize()) {
        BoxWithConstraints(modifier = Modifier.weight(1f)) {
            Surface {
                Column(
                    modifier = Modifier
                        .fillMaxSize()
                        .verticalScroll(scrollState),
                ) {

                    ProfileHeader(
                        actions.toAboutMe,
                        scrollState,
                        this@BoxWithConstraints.maxHeight
                    )
                    UserInfoFields(
                        actions.enterArticle,
                        actions.toLogin,
                        this@BoxWithConstraints.maxHeight
                    )
                }
            }
            ProfileFab(
                themeViewModel = themeViewModel,
                extended = scrollState.value == 0,
                modifier = Modifier.align(Alignment.BottomEnd)
            )
        }
    }

1 column 增加verticalScroll 修饰 就可以滑动起来
2 BoxWithConstraints 这个组件提供了获取 自己最大高度 与 最大宽度的方法

上一篇下一篇

猜你喜欢

热点阅读