gpt4 book ai didi

android - Unresolved reference : lparams for verticalLayout in Anko 0. 10.6

转载 作者:行者123 更新时间:2023-11-29 18:43:12 26 4
gpt4 key购买 nike

我看过Anko 0.8 - unresolved lparams reference ,但我没有像该链接那样在最外层布局中使用 lparams。

我在以下代码中得到“ Unresolved 引用:lparams”(Android Studio 中没有导入建议)。关于我遗漏和/或忽略的内容有什么想法吗?

class LoginActivityUi: AnkoComponent<LoginActivity> {

override fun createView(ui: AnkoContext<LoginActivity>): View = with(ui) {
verticalLayout {
backgroundColorResource = R.color.background_page

textView{
text = "ASDF"
}.lparams{

}
}
}

}

这是我的依赖项($kotlin_version 是 1.2.71,$anko_version 是 0.10.6):

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation "org.jetbrains.anko:anko-commons:$anko_version"

// Appcompat-v7 (only Anko Commons)
implementation "org.jetbrains.anko:anko-appcompat-v7-commons:$anko_version"

// Appcompat-v7 (Anko Layouts)
implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
implementation "org.jetbrains.anko:anko-coroutines:$anko_version"

// Anko Layouts
implementation "org.jetbrains.anko:anko-sdk15:$anko_version" // sdk15, sdk19, sdk21, sdk23 are also available
implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

// Coroutine listeners for Anko Layouts
implementation "org.jetbrains.anko:anko-sdk15-coroutines:$anko_version"
implementation "org.jetbrains.anko:anko-appcompat-v7-coroutines:$anko_version"

// CardView-v7
implementation "org.jetbrains.anko:anko-cardview-v7:$anko_version"

// Design
implementation "org.jetbrains.anko:anko-design:$anko_version"
implementation "org.jetbrains.anko:anko-design-coroutines:$anko_version"

// GridLayout-v7
implementation "org.jetbrains.anko:anko-gridlayout-v7:$anko_version"

// Percent
implementation "org.jetbrains.anko:anko-percent:$anko_version"

// RecyclerView-v7
implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
implementation "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"

// Support-v4 (only Anko Commons)
implementation "org.jetbrains.anko:anko-support-v4-commons:$anko_version"

// Support-v4 (Anko Layouts)
implementation "org.jetbrains.anko:anko-support-v4:$anko_version"

// ConstraintLayout
implementation "org.jetbrains.anko:anko-constraint-layout:$anko_version"
}

最佳答案

好的,所以... 正如您在 this diff 中看到的那样,从 Anko 0.10.6 开始,verticalLayout 方法被修改为采用 LinearLayout.() -> Unit 类型的初始化 lambda 而不是之前的 _LinearLayout .() -> 单位 类型。带下划线的 _LinearLayout 类是定义您要查找的 lparams 方法的类,这就是它因此次更改而丢失的原因。

这里已经有一个针对此重大更改的未解决问题:https://github.com/Kotlin/anko/issues/673

与此同时,您可以坚持使用 0.10.5,也可以使用具有明确方向的 linearLayout 作为解决方法:

linearLayout {
orientation = LinearLayout.VERTICAL
backgroundColorResource = R.color.background_page

textView {
text = "ASDF"
}.lparams {

}
}

关于android - Unresolved reference : lparams for verticalLayout in Anko 0. 10.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52575129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com