Android Studio XML无法识别objectAnimator

问题描述 投票:12回答:1

我一直试图动画两个片段之间的过渡。我最初在xml中放置了一个属性动画(并没有真正起作用),然后将其更改为objectAnimator。由于某些原因,Android Studio无法识别objectAnimator标记。

这是我的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.nick.randomapplication" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Base.AppCompat.Light" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

我的build.Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.nick.randomapplication"
        minSdkVersion 19
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:20.0.+"
}

和xml文件:

<?xml version="1.0" encoding="utf-8"?>

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android">

</objectAnimator>

感谢您花时间看看这个。我不知道该怎么做了。

android xml android-fragments android-studio objectanimator
1个回答
40
投票

我认为您已将xml文件放在错误的文件夹中。

valueAnimator objectAnimatoranimatorSet资源应该在文件夹res / animator中,而不是在res / anim中。

请访问android开发者以获取更多信息。 http://developer.android.com/guide/topics/resources/animation-resource.html

© www.soinside.com 2019 - 2024. All rights reserved.