Is there an XML equivalent of Android’s loadAnimation function? I want to specify the animation to apply to a view in my layout XML.
I have an animation defined in an animation resource:
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="359"
android:pivotX="50%"
android:pivotY="50%"
android:duration="10000"
android:repeatCount="infinite" />
How can I do the below in my layout XML?
ImageButton main_button = (ImageButton)this.findViewById(R.id.imageButton1);
Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.my_rotate);
main_button.startAnimation(rotateAnimation);
You cannot do this from XML 🙂