android-pathview
介绍:
path动画,可以从svg或者是path中绘制。
运行效果:
使用说明:
有两种类型的path:
1. 从 Svg
<com.eftimoff.androipathview.PathView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pathView"
android:layout_width="150dp"
android:layout_height="150dp"
app:pathColor="@android:color/white"
app:svg="@raw/settings"
app:pathWidth="5"/>
结果
2. 从 Path
<com.eftimoff.androipathview.PathView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/pathView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:pathColor="@android:color/white"
app:pathWidth="3"/>
代码
final Path path = new Path();
path.moveTo(0.0f, 0.0f);
path.lineTo(length / 4f, 0.0f);
path.lineTo(length, height / 2.0f);
path.lineTo(length / 4f, height);
path.lineTo(0.0f, height);
path.lineTo(length * 3f / 4f, height / 2f);
path.lineTo(0.0f, 0.0f);
path.close();
pathView.setPath(path);
结果
使用 animator
pathView.getPathAnimator()
.delay(100)
.duration(500)
.listenerStart(new AnimationListenerStart())
.listenerEnd(new AnimationListenerEnd())
.interpolator(new AccelerateDecelerateInterpolator())
.start();
如果想使用svg颜色
pathView.useNaturalColors();
如果想在动画后绘制真正的SVG
pathView.setFillAfter(true);
下载
dependencies {
compile 'com.eftimoff:android-pathview:1.0.6@aar'
}
已下载
0