I just started learning animations and I was wondering how can I set the duration of an animation (scale, translate, rotate etc..) in the XML file?
This is my translate.xml resource file:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="-1000"
android:toXDelta="0">
</translate>
I watched some tutorials on Youtube and noticed that they used android:duration="2000"
(this means 2 seconds if I'm not mistaken?), something like this:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="-1000"
android:toXDelta="0"
android:duration="2000">
</translate>
However, I was unable to add that line of code inside my XML file. I am doing something wrong here?
UPDATE: After multiple times of restarting my Android Studio project, I was able to add that line of code. (Previously the IDE was displaying red squiggly lines)
everything looks fine, duration
should work as TranslateAnimation extends
Animation, which handle duration
attribute