Android 在xml布局中创建自定义微调器

Android 在xml布局中创建自定义微调器,android,android-layout,android-spinner,Android,Android Layout,Android Spinner,我想创建一个自定义微调器,以便在整个应用程序中重复使用。因此,我希望将微调器创建为xml布局文件(即/layout/custom_spinner.xml)。我已经创建了可绘制列表 <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> &

我想创建一个自定义微调器,以便在整个应用程序中重复使用。因此,我希望将微调器创建为xml布局文件(即/layout/custom_spinner.xml)。我已经创建了可绘制列表

<?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>

现在我需要知道如何把它放在我的旋转器里。典型的xml微调器如下所示

<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" />

我如何实现我想要的

编辑:

以下基本上可以工作,但它显示了四个进度微调器/条,而不是中间的一个

 <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" />


android中的术语
微调器
指的不是
进度条

但是,请查看
setProgressDrawable(Drawable d)
setIndeterminateDrawable(Drawable d)
方法

您需要删除此行

style=“?android:attr/progressBarStyleLarge”

编辑:



我在文档中找不到特定的旋转可绘制信息,因此我不确定它需要包装在什么内容中(如果有的话)。

那么我是否将我的动画列表视为可绘制?我该怎么做呢?还有一种叫做setAnimation的方法。我不知道该使用哪一个或如何使用它们。@cote mounyo,一个
动画列表
是可绘制的。请在这个SO岗位上多多关注。这里有很多答案。谢谢你的帮助(+1)。我想我快到了。请参阅我的编辑,了解我遇到的新问题。@CoteMounyo,你想让火箭飞船旋转吗?我认为绘制效果取决于你希望达到的动画效果。
<rotate android:drawable="@drawable/my_icon" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" />