androiddrawabletext-manipulationanimationdrawable

Quick way to add hundreds of items to an XML <animation-list> element


I have to add up to 100 .png's to create an AnimationDrawable on Android.

Luckily, the png's are named in ascending order (p1, p2, p3, p4).

Manually adding all pngs into the XML element is painfully slow, so I'm wondering if there's a way to automatically 'increment' a filename to a certain limit.

The method does not have to use Android Studio. Any text manipulation program will do. Below is an example of a desired result:

<animation-list android:id="@+id/selected"
android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/p1" android:duration="500" />
<item android:drawable="@drawable/p2" android:duration="500" />
<item android:drawable="@drawable/p3" android:duration="500" />
<item android:drawable="@drawable/p4" android:duration="500" />
...
...
...
<item android:drawable="@drawable/p99" android:duration="500" />


</animation-list>

Solution