programing

androidX 라이브러리에없는 BottomSheetBehavior

yoursource 2021. 1. 16. 10:54
반응형

androidX 라이브러리에없는 BottomSheetBehavior


BottomSheetBehavior원래 지원 라이브러리와 함께 사용했습니다 .

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

누락 androidx되었지만 라이브러리 를 사용하기 위해 마이그레이션했을 때 BottomSheetBehavior. 위 지원 라이브러리의 매핑은 AndroidX 리팩터링 목록 에도 없지만 마이그레이션 도구에서 제거했습니다.

androidx라이브러리에 BottomSheetBehavior를 포함하기 위해 내가 놓친 것은 무엇입니까?

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"
    />

당신은 또한 대체 할 수 있습니다

    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
or 
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"

으로

app:layout_behavior="@string/bottom_sheet_behavior"

You have to import the Material Components Library provided by Google.

Material Components for Android is a drop-in replacement for Android's Design Support Library.

Add in your build.gradle:

implementation 'com.google.android.material:material:x.x.x'

Then use the class com.google.android.material.bottomsheet.BottomSheetBehavior.

In your layout can use the attribute:

    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    ..>

ReferenceURL : https://stackoverflow.com/questions/51617186/bottomsheetbehavior-not-in-androidx-libraries

반응형