0
我想创建一个自定义微调控件,我想在整个应用程序中重新使用它。因此,我想创建我的微调为xml布局文件(即/layout/custom_spinner.xml)。我已经创建了可绘制列表在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" />
那么,我将我的动画列表视为可绘制的?我怎么做? –
还有一种叫做setAnimation的方法。我不确定要使用哪一个或如何使用它们。 –
@ cote-mounyo,一个'动画列表'是一个可绘制的。已经在这个SO帖子http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog。有很多答案。 – techiServices