You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jetpack Compose:如何在LazyColumn中实现版权文本居底且不使用Column?

解决方法

你可以通过以下方式实现版权文本固定在屏幕底部的需求,无需使用Column或带weight(1f)的Spacer:

LazyColumn(
    modifier = Modifier.fillMaxSize()
) {
    item {
        Text("Some text...")
        Text("Some text...")
    }
    item(modifier = Modifier.fillMaxHeight()) {
        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.BottomCenter
        ) {
            Text("Copyright © Max 2024")
        }
    }
}

原理说明

  • 给承载版权文本的item设置Modifier.fillMaxHeight(),让该item占据屏幕剩余的全部垂直空间
  • 使用Box作为容器,通过contentAlignment = Alignment.BottomCenter将文本定位到容器(即屏幕)的底部

内容的提问来源于stack exchange,提问作者Always Learner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 23:03:21