小编sim*_*lsi的帖子

如何避免模态底部工作表与 Android 中的系统导航图标重叠

Material3 模态底部表单当前与系统导航按钮重叠。有没有办法避免与系统导航按钮重叠。

这是我用来显示模态底部工作表的代码


@Composable
fun TestScreen() {
    var sheetOpened by mutableStateOf(false)

    Scaffold() {
       Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
         Button(onClick = { sheetOpened = true }){
              Text("Open Bottom Sheet")  
          }
       }
    }

    if(sheetOpened){
        ModalBottomSheet(onDismissRequest = {sheetOpened = false}){
            Box(Modifier.fillMaxWidth().height(500.dp).background(Color.RED))
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

尝试将模态底板放入脚手架内,但这也不起作用。

android android-jetpack-compose android-jetpack-compose-material3

9
推荐指数
1
解决办法
1533
查看次数

在模块中发现重复的类

我正在开发一个多模块 Android 项目。以前编写的模块之一使用 Paging 库 version-2,现在我尝试在另一个模块中使用新的 paging v3 库,但出现此错误。

Duplicate class androidx.paging.LivePagedListKt found in modules jetified-paging-runtime-ktx-2.1.2-runtime.jar (androidx.paging:paging-runtime-ktx:2.1.2) and paging-runtime-3.0.0-alpha03-runtime.jar (androidx.paging:paging-runtime:3.0.0-alpha03)

模块层次结构是这样的:

       app:
   /         \
module-A    module-B
(uses v2)   (uses v3)
Run Code Online (Sandbox Code Playgroud)

我在 app 模块 build.gradle 中添加了模块 A 和模块 B 的依赖项,就像这样

implementation project(path: ':module-A')
implementation project(path: ':module-B')
Run Code Online (Sandbox Code Playgroud)

有没有什么办法可以在同一个项目中使用同一个库的不同版本,前提是在不同的模块中使用不同的版本

到目前为止尝试的解决方案:

我查看了类似的答案并在应用程序级 build.gradle 文件中添加了这一行

configurations {
    runtime.exclude group: 'androidx.paging', module: 'paging-runtime'
}
Run Code Online (Sandbox Code Playgroud)

但仍然得到同样的错误。

android gradle android-gradle-plugin

7
推荐指数
1
解决办法
1092
查看次数