我想在顶部栏下面添加一个水平分隔线,如下所示:

enter image description here

我用的是material 3,但分割线不能解决.以下是我的依赖项:

 dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation 'androidx.compose.material3:material3:1.0.0-alpha01'
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}

以下是我的代码:

 Scaffold(
        topBar = {
            SmallTopAppBar(
                navigationIcon = {
                    IconButton(
                        onClick = {}) {
                        Icon(
                            imageVector = Icons.Default.ArrowBack,
                            contentDescription = "Back",
                            tint = Color.Black
                        )
                    }
                },
                title = {
                    Text(
                        text = "",
                        color = MaterialTheme.colorScheme.onPrimary
                    )
                },
            )
        }
    ) {
        Box {
            Divider(color = Color.Gray, thickness = 1.dp)

        }

    }

但正如我上面提到的,Divider是一个未解决的引用:

enter image description here

推荐答案

请升级到:

    implementation 'androidx.compose.material3:material3:1.0.0-alpha15'

Android相关问答推荐

当X为lambda函数时,如何避免Android Studio错误检测参数X未使用?

从单元测试访问RES/RAW文件

LocalContext.current的问题(@Composable调用只能从@Composable函数的上下文发生)

不能在LazyGrid-Jetpack Compose中使用填充最大宽度或填充父项最大宽度

使用Android Jetpack Compose,为子Composable定义ViewModel是不是一种糟糕的做法?

如何在喷气背包中绕过集装箱

仅当先前输入为 yes 时,Android 才会要求下一个输入

如何禁用自动登录 google play games services android unity?

Material 3的MaterialSwitch默认大小太大了?如何使它变小?

[Android][Room] 将密封类存储到 Room 数据库中

在 Jetpack Compose 中包装内容

Jetpack Compose Arc 进度条动画(如何重启动画)

没有互联网连接时,Firebase Storage putFile() 永远不会完成

如何在最后一个可见项目之后计算惰性列中的空白空间

Gradle 构建错误:找不到 semver4j-0.16.4-nodeps.jar

使 Compose LazyColumn 的最后一项填满屏幕的其余部分

更新应用程序是否会取消对应用程序特定文件的权限?

Android YouTube SDK - 视频无法在某些 Android 设备中播放

实际类型别名ApplicationContext没有相应的预期声明

验证备份 ZIP 文件