gpt4 book ai didi

android - 如何改变Android中循环进度的颜色和图案?

转载 作者:行者123 更新时间:2023-11-29 18:08:28 26 4
gpt4 key购买 nike

我使用下面的代码生成循环进度。但是我不知道如何改变它的图案和颜色。

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

它产生了如下循环进度:

enter image description here

但我需要像下面这样更改颜色和图案:

enter image description here

我不想实现音乐图标。我只希望进度模式和颜色看起来像第二张图片。

最佳答案

您需要使用 AnimationDrawable根据您的要求上课,

在 res/drawable/文件夹中创建 spin_animation.xml 文件:

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

使用以下代码执行,

 // 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 - 如何改变Android中循环进度的颜色和图案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12119313/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com