如何使用objectAnimator为drawables制作动画

时间:2016-09-20 17:23:54

标签: android objectanimator

我想添加一个旋转drawable作为按钮的drawableRight,但它不起作用。 drawable显示在按钮的文本旁边,但它没有旋转。这是我试图使用的代码。

Drawable loader = ContextCompat.getDrawable(getActivity(), R.drawable.ic_rotate_right);

                ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(loader,
                        "rotation", 0f, 360f);
                rotateAnim.setDuration(500);
                rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
                rotateAnim.setRepeatCount(ValueAnimator.RESTART);
                rotateAnim.start();

                simpleButton.setCompoundDrawablesWithIntrinsicBounds(null, null, loader, null);

请您知道如何实现这一目标吗?

注意: drawable是一个可绘制的矢量。

0 个答案:

没有答案
相关问题