相关疑难解决方法(0)

Android圈子复选标记动画

我正在尝试实现类似于BEMAnimationTypeStroke的东西,它可以在iOS库BEMCheckBox中找到.

我已经尝试使用动画矢量drawable来实现这一点,但我不知道如何设置圆圈内的复选标记从0起点到最终位置的动画.(圆圈可以是静态的,我希望为复选标记设置动画).这是我为此尝试的实现:

绘制/ vector_drawable_ic_check_circle_white_48px.xml

    <path
            android:name="check"
            android:fillColor="#FFFFFF"
            android:pathData="M37.1,13.6L18.4,32.3h1.7l-8.5-8.5L10,25.5l8.5,8.5l0.8,0.8l0.8-0.8l18.7-18.7L37.1,13.6L37.1,13.6z"/>
    <path
            android:name="circle"
            android:fillColor="#FFFFFF"
            android:pathData="M24,48c13.3,0,24-10.7,24-24S37.3,0,24,0S0,10.7,0,24S10.7,48,24,48L24,48z
M24,45.6
C12.1,45.6,2.4,35.9,2.4,24S12.1,2.4,24,2.4S45.6,12.1,45.6,24S35.9,45.6,24,45.6L24,45.6z"/>
</vector>
Run Code Online (Sandbox Code Playgroud)

动画/ transform.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
            android:duration="1000"
            android:propertyName="fillColor"
            android:valueFrom="@color/transparent"
            android:valueTo="@color/white"/>
</set>
Run Code Online (Sandbox Code Playgroud)

绘制/ animation.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:drawable="@drawable/vector_drawable_ic_check_circle_white_48px">
    <target
            android:name="check"
            android:animation="@anim/change_color"/>
</animated-vector>
Run Code Online (Sandbox Code Playgroud)

设置布局后,我使用以下命令启动动画:

ImageView mCpuImageView = (ImageView) findViewById(R.id.animated_check);
Drawable drawable = mCpuImageView.getDrawable();
if (drawable instanceof Animatable) {
    ((Animatable) drawable).start();
}
Run Code Online (Sandbox Code Playgroud)

谁能帮我这个?有没有更简单的方法来实现这一点(自定义视图或现有库)?

我的想法是,我希望在一个圆圈中有一个复选标记,我想要勾选复选标记的路径.显示时,只显示圆圈,然后创建复选标记动画.如果其他自定义,例如同时为复选标记设置动画的动画,则很容易实现它会更好,但起初我只想为复选标记设置动画.

LE: 最后我选择了通过自定义View手动创建动画的方法.如果有人知道如何通过矢量绘制实现这一点,它将是一个很好的开发实践.谢谢.

animation android checkmark android-vectordrawable

3
推荐指数
3
解决办法
1万
查看次数