我正在尝试在此url上使用官方的Google Jetpack撰写教程,但是Android Studio在解决修饰符 Height()
时存在问题我100%确信我已按照教程导入了正确的依赖关系,但是,找不到该修饰符。它不被弃用,因为它仍然是官方文档here
中的引用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")
}
}
我想念什么吗?
答案 0 :(得分:1)
我假设您正在使用dev02
(因为未更新Google文档)对 ui-layout 的依赖,因为 Height()已添加在< strong> dev03 。将您的用户界面布局依赖性更改为 dev03 :
implementation 'androidx.ui:ui-layout:0.1.0-dev03'
应该可以
答案 1 :(得分:0)
我需要添加以下内容以使事情运行:
//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'
}
答案 2 :(得分: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}"
],
答案 3 :(得分:0)
Geoff Langenderfer说从dev09
改成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'
}