Material 3 中用于 Compose 的 ModalBottomSheet

huangapple go评论72阅读模式
英文:

ModalBottomSheet in Material 3 for compose

问题

I have switched from Material 2 to Material 3 in my android compose project :

我已经将我的Android Compose项目从Material 2切换到Material 3:

I have this dependencie which is the latest stable one :

我有这个依赖项,它是最新的稳定版本:

implementation ("androidx.compose.material3:material3:1.0.1")

根据文档,我应该能够导入并使用ModalBottomSheet:

但是在导入时,我遇到了未解决的引用问题:

import androidx.compose.material3.ModalBottomSheet

All my others M3 components are fine.

我所有其他的M3组件都正常。

Can anyone help me on how I can import ModalBottomSheet without problem ?

英文:

I have switched from Material 2 to Material 3 in my android compose project :

I have this dependencie which is the latest stable one :

implementation ("androidx.compose.material3:material3:1.0.1")

As mention in the docs i should be able to import and use the ModalBottomSheet :

https://developer.android.com/reference/kotlin/androidx/compose/material3/package-summary#ModalBottomSheet(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.material3.SheetState,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.ui.unit.Dp,androidx.compose.ui.graphics.Color,kotlin.Function0,kotlin.Function1)

But i get unresolved reference when importing :

import androidx.compose.material3.ModalBottomSheet

All my others M3 components are fine.

Can anyone help me on how I can import ModalBottomSheet without problem ?

答案1

得分: 6

你需要使用Material 3的版本1.1.0-alpha06,因为这是一个非常新的添加。请查看发布说明此处

英文:

You need to use Version 1.1.0-alpha06 of Material 3 as this is a very recent addition. Please have a look at the release notes here.

答案2

得分: 1

你需要在Gradle模块级别的文件中将compose-bom更新到最新版本,如下所示:

implementation(platform("androidx.compose:compose-bom:2023.08.00"))

目前最新版本是2023.08.00,随时可以根据需要进行更改。

英文:

You need to update the compose-bom to latest version in gradle module level file
like this:

implementation(platform("androidx.compose:compose-bom:2023.08.00"))

currently the latest version is 2023.08.00 when ever you want it change it according.

huangapple
  • 本文由 发表于 2023年2月14日 03:46:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440545.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定