本文介绍了如何改变在Android上circualar进步的颜色和图案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code生成圆形进度。但我不知道如何改变它的花纹和色泽。
I use the below code to generate the circular progress. But I don't know how to change the pattern and color of it.
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="10%" android:pivotY="10%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="0"
android:thicknessRatio="6" android:useLevel="false">
<size android:width="10dip" android:height="10dip" />
<gradient android:type="linear" android:useLevel="false"
android:startColor="#000000"
android:endColor="#000000"
android:angle="0"
/>
</shape>
</rotate>
它产生的圆形进度如下图所示:
It generated the circular progress like below:
不过,我需要改变颜色和图案象下面这样:
But I need to change the color and pattern like below:
我不想要实现音乐的图标。我只是想进步图案和颜色看起来像第二个图像。
I don't want to implement the music icon. I just want the progress pattern and the color to look like the second image.
推荐答案
您需要使用的类的要求,
You need to use the AnimationDrawable class for your requirement,
创建RES /绘制/文件夹spin_animation.xml文件:
create spin_animation.xml file in res/drawable/ folder:
<!-- Animation frames are wheel0.png -- wheel5.png files inside the
res/drawable/ folder -->
<animation-list android:id="@+id/selected" android:oneshot="false">
<item android:drawable="@drawable/wheel0" android:duration="50" />
<item android:drawable="@drawable/wheel1" android:duration="50" />
<item android:drawable="@drawable/wheel2" android:duration="50" />
<item android:drawable="@drawable/wheel3" android:duration="50" />
<item android:drawable="@drawable/wheel4" android:duration="50" />
<item android:drawable="@drawable/wheel5" android:duration="50" />
</animation-list>
使用下面的code来执行,
Use following code to execute,
// Load the ImageView that will host the animation and
// set its background to our AnimationDrawable XML resource.
ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
img.setBackgroundResource(R.drawable.spin_animation);
// Get the background, which has been compiled to an AnimationDrawable object.
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// Start the animation (looped playback by default).
frameAnimation.start();
这篇关于如何改变在Android上circualar进步的颜色和图案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!