android compose LazyVerticalGrid上下滚动的网格布局 使用

android compose LazyVerticalGrid上下滚动的网格布局 使用

复制代码
/**
 * Author : wn
 * Email : maoning20080809@163.com
 * Date : 2026/1/9 22:00
 * Description : LazyVerticalGrid滚动的网格布局
 */
class LazyVerticalGridActivity : ComponentActivity(){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            testLazyVerticalGrid()
        }
    }

    @Preview
    @Composable
    private fun testLazyVerticalGrid(){
        val items = (1..100).toList()
        Column() {
            Spacer(modifier = Modifier.height(20.dp))
            Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center){
                Column(horizontalAlignment = Alignment.CenterHorizontally) {
                    Text(text = "LazyVerticalGrid上下滚动的网格布局", fontSize = 20.sp, color = Color.Green)
                    Spacer(modifier = Modifier.height(20.dp))
                    Text(text = "排列从左到右  -> ", fontSize = 30.sp, color = Color.Black)
                }
            }

            LazyVerticalGrid(GridCells.Fixed(4), contentPadding = PaddingValues(16.dp), content = {
                items(items){ item ->
                    Box(modifier = Modifier.size(50.dp).padding(6.dp)
                        .background(Color.Green), contentAlignment = Alignment.Center, content = {
                        Text(text = item.toString())
                    })
                }
            })
        }

    }
}
相关推荐
Doro再努力16 小时前
【Linux操作系统10】Makefile深度解析:从依赖推导到有效编译
android·linux·运维·服务器·编辑器·vim
Daniel李华17 小时前
echarts使用案例
android·javascript·echarts
做人不要太理性18 小时前
CANN Runtime 运行时组件深度解析:任务调度机制、存储管理策略与维测体系构建逻辑
android·运维·魔珐星云
我命由我1234518 小时前
Android 广播 - 静态注册与动态注册对广播接收器实例创建的影响
android·java·开发语言·java-ee·android studio·android-studio·android runtime
朗迹 - 张伟18 小时前
Tauri2 导出 Android 详细教程
android
lpruoyu19 小时前
【Android第一行代码学习笔记】Android架构_四大组件_权限_持久化_通知_异步_服务
android·笔记·学习
独自破碎E20 小时前
【BISHI15】小红的夹吃棋
android·java·开发语言
李堇1 天前
android滚动列表VerticalRollingTextView
android·java
lxysbly1 天前
n64模拟器安卓版带金手指2026
android
游戏开发爱好者81 天前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview