Reputation: 13965
I want to create a custom spinner that I want to re-use throughout my app. Hence, I want to create my spinner as an xml layout file (i.e. /layout/custom_spinner.xml). I have already created by drawable list
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
Now I need to know how to place it inside my spinner. The typical xml spinner looks like this
<ProgressBar
android:id="@+id/spinner"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible" />
How do I accomplish what I want?
EDIT:
The following basically works, but it shows four progress spinners/bars instead of one in the center.
<ProgressBar
android:id="@+id/spinner"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/my_icon"
android:visibility="visible" />
Upvotes: 0
Views: 804
Reputation: 8533
The term Spinner
in android refers to something other than a ProgressBar
.
However, look at the setProgressDrawable(Drawable d)
and setIndeterminateDrawable(Drawable d)
methods.
You will need to remove this line
style="?android:attr/progressBarStyleLarge"
EDIT:
<rotate android:drawable="@drawable/my_icon" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" />
I can't find the specific rotate drawable info in the docs so I am unsure what it needs to be wrapped in, if anything.
Upvotes: 1