3

我正在尝试在此url上遵循官方 google Jetpack 撰写教程,但 Android 工作室在解决修饰符Height()时遇到问题

我 100% 确定我已按照教程导入了正确的依赖项,但是,找不到此修饰符。它没有被弃用,因为它仍然在官方文档中引用

fun NewsStory() {
    val image = +imageResource(R.drawable.header)
        Column(
            modifier = Spacing(16.dp)
            ) {
            Container(modifier = Height(180.dp) wraps Expanded) {
                DrawImage(image)
            }

            HeightSpacer(16.dp)

            Text("A day in Shark Fin Cove")
            Text("Davenport, California")
            Text("December 2018")
        }
}

我错过了什么吗?

4

4 回答 4

3

我假设您正在使用ui-layoutdev02依赖项(因为 Google 的文档未更新)依赖项,因为在dev03中添加了Height()。将您的 ui-layout 依赖项更改为dev03

implementation 'androidx.ui:ui-layout:0.1.0-dev03'

它应该工作

于 2019-12-15T15:03:54.417 回答
1

我需要添加以下内容才能运行:

//app/build.gradle
...
dependencies {

    ...                                                                   

    //Jetpack Compose
    implementation 'androidx.compose:compose-compiler:0.1.0-dev09'
    implementation 'androidx.compose:compose-runtime:0.1.0-dev09'
    implementation 'androidx.ui:ui-layout:0.1.0-dev09'
    implementation 'androidx.ui:ui-material:0.1.0-dev09'
    implementation 'androidx.ui:ui-tooling:0.1.0-dev09'
    implementation 'androidx.ui:ui-framework:0.1.0-dev09'
}
于 2020-05-08T19:11:00.557 回答
0

正如Geoff Langenderferdev09所说,从工作转变为dev03工作。

//app/build.gradle
 dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.1.0'

    implementation 'androidx.ui:ui-framework:0.1.0-dev09'
    implementation 'androidx.ui:ui-layout:0.1.0-dev09'
    implementation 'androidx.ui:ui-material:0.1.0-dev09'
    implementation 'androidx.ui:ui-tooling:0.1.0-dev09'

    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
于 2020-06-03T07:38:19.367 回答
0

就 Jetpack Compose Dependencies 而言,这是我的设置。您不需要所有这些,因此请随意跳过超级特定的 - https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example/blob/master/build.gradle#L24

贴在这里供参考

'compose': [
                    'composeComplier': "androidx.compose:compose-compiler:${versions.compose}",
                    'composeRuntime': "androidx.compose:compose-runtime:${versions.compose}",
                    'core': "androidx.ui:ui-core:${versions.compose}",
                    'foundation': "androidx.ui:ui-foundation:${versions.compose}",
                    'tooling': "androidx.ui:ui-tooling:${versions.compose}",
                    'layout': "androidx.ui:ui-layout:${versions.compose}",
                    'material': "androidx.ui:ui-material:${versions.compose}",
                    'savedInstanceState': "androidx.ui:ui-saved-instance-state:${versions.compose}",
                    'uiTest': "androidx.ui:ui-test:${versions.compose}",
                    'uiLiveData': "androidx.ui:ui-livedata:${versions.compose}"
            ],
于 2020-05-23T19:07:15.583 回答