Jim*_*ask 63 bottom-sheet androidx
我正在使用BottomSheetBehavior原始支持库:
implementation 'com.android.support:design:27.1.1'
Run Code Online (Sandbox Code Playgroud)
当我迁移使用新androidx库时虽然BottomSheetBehavior缺少了.上述支持库的映射也不在AndroidX重构列表中,但迁移工具将其删除.
我错过了将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'
}
Run Code Online (Sandbox Code Playgroud)
Jim*_*ask 166
事实证明,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"
/>
Run Code Online (Sandbox Code Playgroud)
新的位置是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"
/>
Run Code Online (Sandbox Code Playgroud)
Jos*_*hon 41
你也可以替换
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
or
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
Run Code Online (Sandbox Code Playgroud)
通过
app:layout_behavior="@string/bottom_sheet_behavior"
Run Code Online (Sandbox Code Playgroud)
Gab*_*tti 27
您必须导入Google 提供的Material Components Library。
适用于 Android 的 Material Components 是 Android 设计支持库的直接替代品。
添加您的build.gradle:
implementation 'com.google.android.material:material:x.x.x'
Run Code Online (Sandbox Code Playgroud)
然后使用类com.google.android.material.bottomsheet.BottomSheetBehavior。
在您的布局中,您可以使用该属性:
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
..>
Run Code Online (Sandbox Code Playgroud)
或者
app:layout_behavior="@string/bottom_sheet_behavior"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15957 次 |
| 最近记录: |