Reputation: 8151
I found the pngs for the standard progress spinner in Android. However, when I try to animate them in a similar way to how android does it with the following code nothing happens. They just appear to be a static icons.
The button
<Button
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@anim/anim"
android:drawableRight="@anim/anim" >
</Button>
The animation
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:drawable="@drawable/spinner_76_outer_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="0"
android:toDegrees="1080" />
</item>
<item>
<rotate
android:drawable="@drawable/spinner_76_inner_holo"
android:pivotX="50%"
android:pivotY="50%"
android:fromDegrees="720"
android:toDegrees="0" />
</item>
</layer-list>
Is it even possible to start animations automatically that is defined in XML only or do they have to be started with java?
Upvotes: 0
Views: 202
Reputation: 134664
You can use animated-rotate
but that will only work on API 11+. If you use rotate
, then you'll have to start them in Java, and animate them by animating the level (drawable.setLevel()
) between 0
and 10000
(sounds weird? It is, but it's how it's done).
Upvotes: 1