MaterialContainerTransform

MaterialContainerTransform

我从 Material 设计过渡开始。

根据documentation,我应该将以下内容添加到我的应用gradle.build文件中。我做到了

dependencies {
//...
   api 'com.google.android.material:material:1.1.0'
}

(我也尝试过implementation 'com.google.android.material:material:1.1.0',因为github documentation还显示了使用implementation代替api)。那么,哪一个是对的?

但是,当我开始使用MaterialContainerTransform时,出现错误“ Unresolved reference :MaterialContainerTransform”

android - MaterialContainerTransform Unresolved reference-LMLPHP

我专门进口
import com.google.android.material.transition.platform.MaterialContainerTransform

但是我仍然得到错误。
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
        setPreferencesFromResource(R.xml.notifications_preferences, rootKey)


        sharedElementEnterTransition = MaterialContainerTransform(requireContext())
}

如何使我的项目使用MDC?

这是我完整的Gradle文件。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {

    compileSdkVersion 29
    def versionMajor = 2020
    def versionMinor = 10
    def versionPatch = 3
    def versionPatchMinor = 0

    defaultConfig {
        applicationId "com.mycompany.myapp"
        vectorDrawables.useSupportLibrary = true

        minSdkVersion 25
        targetSdkVersion 29

        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch * 10 + versionPatchMinor
        versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionPatchMinor}"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true

        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
        }

        compileOptions.with {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }




    buildTypes {

        debug {
            minifyEnabled false
            debuggable true
        }


        release {

            debuggable true
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        dataBinding = true
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    configurations {
        cleanedAnnotations
        compile.exclude group: 'org.jetbrains', module: 'annotations'
    }
}

dependencies {

    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    api 'com.google.android.material:material:1.1.0'


    implementation 'org.jetbrains:annotations-java5:15.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'

    implementation 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
    implementation 'androidx.core:core:1.3.0'
    implementation "androidx.core:core-ktx:1.3.0"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.preference:preference:1.1.1'

    implementation 'com.google.code.gson:gson:2.8.6'

    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.squareup.picasso:picasso:2.71828'

    // FIREBASE MESSAGING
    implementation 'com.google.firebase:firebase-messaging:20.2.0'
    implementation 'com.google.firebase:firebase-core:17.4.2'

    // GOOGLE PLAY SERVICES
    implementation 'com.google.android.gms:play-services-location:17.0.0'

    // BARCODE SCANNNIG
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
    implementation 'com.google.zxing:core:3.4.0'

    // SQUARE PAYMENTS
    implementation 'com.squareup.sdk:point-of-sale-sdk:2.0'

    // HERE MAPS
    implementation(name: 'HERE-sdk', ext: 'aar')
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.0.rc1'

    // TESTING
    testImplementation 'junit:junit:4.13'
}

repositories {
    google()
    jcenter()

    // HEREMAPS
    flatDir {
        dirs 'libs'
    }
}

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

最佳答案

MaterialContainerTransform是在1.2.0-alpha05版本中引入的

10-08 15:30