安卓定制水平进度条动画 [英] Android: Custom Horizontal Progress Bar Animation

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

问题描述

我试图创建一个进度条,其中栏本身动画在垂直旋转,因为它的进展水平。我用我的进步绘制经由绘制成功:

 <进度
        机器人:ID =@ + ID /进度
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        风格=@安卓风格/ Widget.ProgressBar.Horizo​​ntal
        机器人:progressDrawable =@可绘制/ custom_progress
        机器人:layout_marginRight =5DP/>
 

下面是我的绘制:

但我希望它有一个微妙的滚动效果,它的进展。因此,它会是什么样子的垂直线条向后移动八九不离十。你跟着?任何帮助是非常AP preciated。谢谢你。

编辑: 我试图创建一个动画列表为我的进步绘制,但我仍然无法看到动画。可以在动画列表是一个剪辑的进度项目里面?

 < XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
<项目机器人:ID =@机器人:ID /背景机器人:可绘制=@可绘制/水沟>< /项目>

<项目机器人:ID =@机器人:ID /进步>

<夹>
    <动画列表安卓单稳=假>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate2机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate3机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate4机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate5机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate6机器人:时间=100/>
        <项目机器人:可绘制=@可绘制/ progress_bar_animate7机器人:时间=100/>
    < /动画列表>
< /剪辑>

< /项目>
< /层列表>
 

解决方案

我不认为这是可以做到我以为它的方式。原因是,我不能引用动画列表,在该点是一个ClipDrawable,并将其转换为一个AnimateDrawable这是必要的,这样我可以以编程方式启动动画。它也有必要包含它在片段组件因为这是因此它只显示图像作为其进展的一部分遮蔽的图像的进度的方式。

除了伪造使用ImageViews我自己的进度条以及那些我没有看到另一种方式解决它这个具体的进度动画。

I'm trying to create a progress bar where the bar itself animates in a vertical spin as it progresses horizontally. I'm successfully using my progress drawable as the drawable via:

<ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="@android:style/Widget.ProgressBar.Horizontal"
        android:progressDrawable="@drawable/custom_progress"
        android:layout_marginRight="5dp" />

Here is my drawable:

But I want it to have a subtle roll effect as its progressing. So it would look like the vertical lines are moving backwards sorta. You follow? Any help is much appreciated. Thanks.

EDIT: I tried created an animation-list as my progress drawable but I'm still not able to see the animation. Can an animation-list be inside of a clip for the progress item?

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background" android:drawable="@drawable/gutter"></item>

<item android:id="@android:id/progress">

<clip>
    <animation-list android:oneshot="false">
        <item android:drawable="@drawable/progress_bar_animate" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate2" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate3" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate4" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate5" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate6" android:duration="100" />
        <item android:drawable="@drawable/progress_bar_animate7" android:duration="100" />
    </animation-list>
</clip>

</item>
</layer-list>

解决方案

I don't think this can be done the way I thought it could. The reason being that I can't reference the animated-list, which at that point is a ClipDrawable, and cast it to an AnimateDrawable which is necessary so I can programmatically start the animation. It's also necessary to contain it in the clip element as that's the ProgressBar's way of masking an image so it only displays part of the image as its progressing.

Aside from faking my own progress bar using ImageViews and animating those I don't see another way around it for this specific ProgressBar.

这篇关于安卓定制水平进度条动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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