我应该实现哪个库才能使用app:layout_behavior =“ @ string / appbar_scrolling_view_behavior”

时间:2019-09-25 09:40:55

标签: android xml android-support-library android-design-library material-components-android

我想在xml文件中添加app:layout_behavior属性,但是不支持。我应该在gradle文件中添加哪个库?

compile 'com.android.support:design:22.2.0

当我添加此编译库时,Android Studio给出了错误,我必须使用androidx库来支持该app:layout_behavior

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.expensemanager"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.0.0'
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.google.firebase:firebase-functions:19.0.1'
    implementation 'androidx.cardview:cardview:1.0.0'


}
apply plugin: 'com.google.gms.google-services'

请帮助我我应该采取哪些措施来支持app:layout_behavior

1 个答案:

答案 0 :(得分:2)

使用Material Components Library(可替代Android的设计支持库)。

implementation 'com.google.android.material:material:1.1.0-beta02'

或最新的稳定版本:

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