Android:为圆形进度动画绘制动画 [英] Android: animate circular progress drawable

查看:498
本文介绍了Android:为圆形进度动画绘制动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个看起来像旋转进度圈的drawable。我想在GridView等内部的ImageView中使用该可绘制对象。

I need a drawable that looks like the rotating progress circle. That drawable I want to use for instance in an ImageView inside a GridView etc.

因此,根据其他帖子,我从\sdk\文件夹中获取了progress_medium_holo.xml。如下所示的平台 android-xx数据 resdrawable。并且我还复制了此drawable使用的PNG文件。

So, according to other posts I took the progress_medium_holo.xml from the folder \sdk\platforms\android-xx\data\res\drawable which looks like this. And I also copied the PNG files which are used by this drawable.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <rotate
             android:drawable="@drawable/spinner_48_outer_holo"
             android:pivotX="50%"
             android:pivotY="50%"
             android:fromDegrees="0"
             android:toDegrees="1080" />
    </item>
    <item>
        <rotate
             android:drawable="@drawable/spinner_48_inner_holo"
             android:pivotX="50%"
             android:pivotY="50%"
             android:fromDegrees="720"
             android:toDegrees="0" />
    </item>
</layer-list>

在我的布局中,例如,我使用了这个ImageView,它是用于进度绘制的。

Within my layout I then used for instance this ImageView which is used the progress-drawable.

<ImageView
    android:id="@+id/element_image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:paddingBottom="5dp"
    android:paddingTop="5dp"
    android:src="@drawable/progress_medium_holo" />

但是结果是静态的圆圈进度。有没有一种方法可以通过XML定义而不使用任何代码对其进行动画处理?

But the result is a static circle-progress. Is there a way to animate that one by XML definition and using no code?

推荐答案

有一个查看名为 ProgressBar 正是您想要的。
只需使用它代替您的 ImageView

<ProgressBar
    android:id="@+id/element_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:paddingBottom="5dp"
    android:paddingTop="5dp" />

这篇关于Android:为圆形进度动画绘制动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆