gpt4 book ai didi

android - BottomSheetBehavior 不在 androidX 库中

转载 作者:行者123 更新时间:2023-12-03 05:31:25 26 4
gpt4 key购买 nike

我将 BottomSheetBehavior 与原始支持库一起使用:

implementation 'com.android.support:design:27.1.1' 

当我迁移到使用新的 androidx 库时,尽管缺少 BottomSheetBehavior 。上述支持库的映射不在 AndroidX Refactoring List 中要么,但迁移工具将其删除。

我缺少什么来将 BottomSheetBehavior 包含在新的 androidx 库中。

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

// ReactiveX
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'

implementation 'com.android.support:design:28.1.0'

// Android Compatability Libraries
// Version: https://developer.android.com/topic/libraries/support-library/refactor
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'

// Android Navigation Component
// Check here for updated version info - will move to androidx soon.
// https://developer.android.com/topic/libraries/architecture/adding-components
def nav_version = "1.0.0-alpha04"

// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version"
androidTestImplementation "android.arch.navigation:navigation-testing-ktx:$nav_version"

// Testing
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}

最佳答案

事实证明,Android Studio 中的重构工具Refactor > Migrate to AndroidX 没有正确迁移 BottomSheetBehaviour 的 XML。

旧位置为android.support.design.widget.BottomSheetBehavior,并且未被迁移工具修改。原始 XML 是:

<fragment
android:id="@+id/player_bottom_sheet_fragment"
android:name="app.rxsongbrowsertrials.ui.player.PlayerToggleFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="56dp"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
/>

新位置是com.google.android.material.bottomsheet.BottomSheetBehavior,因此布局需要变为:

<fragment
android:id="@+id/player_bottom_sheet_fragment"
android:name="app.rxsongbrowsertrials.ui.player.PlayerToggleFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="false"
app:behavior_peekHeight="56dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
/>

关于android - BottomSheetBehavior 不在 androidX 库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51617186/

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