Android Studio XML does not recognize objectAnimator
Asked Answered
S

1

23

I have been trying to animate a transition between two fragments. I had originally placed them a property animations in xml (and that didn't really work), then changed it to objectAnimator. For some reason Android Studio is not recognizing the objectAnimator tag.

here is my 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>

my 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.+"
}

and the xml file:

<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android">
</objectAnimator>

Thank you for taking your time to look at this. I'm not sure what to do anymore.

Skirr answered 4/8, 2014 at 23:9 Comment(2)
facing the same issue... any answers ?Mont
What worked for me : (Note : currently working in Android Studio) : 1. Create anim folder inside the res folder. 2. Right click on the anim folder and add Animation Resource file. 3.Enter the root element as objectAnimator (even if it doesn't show up in the autocomplete suggestions). and Tada!Mont
U
69

I think you have placed the xml file in a wrong folder.

valueAnimator objectAnimator and animatorSet resources should be in the folder res/animator, not in res/anim.

please visit android developer for more information. http://developer.android.com/guide/topics/resources/animation-resource.html

Unbodied answered 19/6, 2015 at 2:27 Comment(2)
Thanks. There are some incorrect comments that led me astray. This got me going again.Alti
Ok, I've just figured out why some people say the folder should be "anim" and some say "animator". If you're using the v4 support library for FragmentTransaction and FragmentManager, you use a folder named "anim", and for the current library name it "animator"Alti

© 2022 - 2024 — McMap. All rights reserved.