android-动画LayerDrawable中的所有RotateDrawables

android-动画LayerDrawable中的所有RotateDrawables,第1张

概述我在图层列表中有两个旋转可绘制对象,并且试图将它们都设置为按钮上的可绘制对象的动画.我正在显示可绘制对象,但没有动画.这是我在xml(button_progress_bar_small.xml)中的可绘制布局:<layer-listxmlns:android="http://schemas.android.com/apkes/android"><item><rot

我在图层列表中有两个旋转可绘制对象,并且试图将它们都设置为按钮上的可绘制对象的动画.我正在显示可绘制对象,但没有动画.

这是我在xml(button_progress_bar_small.xml)中的可绘制布局:

<@R_782_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID"><item>    <rotate         androID:drawable="@drawable/ic_spinner_small_outer"         androID:pivotX="50%"         androID:pivotY="50%"         androID:fromdegrees="0"         androID:todegrees="1080" /></item><item>    <rotate         androID:drawable="@drawable/ic_spinner_small_inner"         androID:pivotX="50%"         androID:pivotY="50%"         androID:fromdegrees="720"         androID:todegrees="0" /></item>

这是我正在运行的代码:

    button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.button_progress_bar_small, 0, 0, 0);    LayerDrawable progressAnimationleft = (LayerDrawable) button.getCompoundDrawables()[0];    ((RotateDrawable) progressAnimationleft.getDrawable(0)).setLevel(500);    ((RotateDrawable) progressAnimationleft.getDrawable(1)).setLevel(500);

我真的不确定动画启动的触发因素是什么,或者我是否应该在每个RotateDrawable上执行某些 *** 作(与LayerDrawable上的一个 *** 作相反)才能做到这一点.

解决方法:

好的,我找到了解决我问题的方法.

我将布局更改为:

<@R_782_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID"><item>    <animated-rotate xmlns:androID="http://schemas.androID.com/apk/res/androID"        androID:drawable="@drawable/ic_spinner_small_outer"        androID:pivotX="50%"        androID:pivotY="50%"        androID:fromdegrees="0"        androID:todegrees="1080"        androID:interpolator="@androID:anim/linear_interpolator"        androID:repeatCount="infinite"/>        </item><item>    <animated-rotate xmlns:androID="http://schemas.androID.com/apk/res/androID"        androID:drawable="@drawable/ic_spinner_small_inner"        androID:pivotX="50%"        androID:pivotY="50%"        androID:fromdegrees="720"        androID:todegrees="0"        androID:interpolator="@androID:anim/linear_interpolator"        androID:repeatCount="infinite"/>        </item>

并将代码更改为:

    button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.button_progress_bar_small, 0, 0, 0);    LayerDrawable progressAnimationleft = (LayerDrawable) button.getCompoundDrawables()[0];    ((Animatable) progressAnimationleft.getDrawable(0)).start();    ((Animatable) progressAnimationleft.getDrawable(1)).start();

它并没有真正回答问题,但是对于我来说,具有相同的动画效果是一个很好的解决方法.

总结

以上是内存溢出为你收集整理的android-动画LayerDrawable中的所有RotateDrawables全部内容,希望文章能够帮你解决android-动画LayerDrawable中的所有RotateDrawables所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1076276.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存