Reputation: 118
Im trying to make a image zoom in by using xml code
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="6000"
android:fromXScale="1dp"
android:fromYScale="1dp"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXScale="150dp"
android:toYScale="150dp"/>
and rotate an image by using
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="4000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360" />
I cant use both scale and rotate in same xml. why? how can i do it?
Upvotes: 2
Views: 2029
Reputation: 658
Blackbelt is right. You have to add the ordering
attribute:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:ordering="together">
<scale
android:duration="6000"
android:fromXScale="1dp"
android:fromYScale="1dp"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="150dp"
android:toYScale="150dp"/>
<rotate
android:duration="4000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360"/>
</set>
Upvotes: 5
Reputation: 157437
you can use a <set>
to combine it. The set is a container that holds other animation elements E.g
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
android:duration="6000"
android:fromXScale="1dp"
android:fromYScale="1dp"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="150dp"
android:toYScale="150dp"/>
<rotate
android:duration="4000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />
</set>
Upvotes: 0