? ? ? ? ? ? ? ? ? 簡(jiǎn)單的矢量圖方法
? 1.導(dǎo)入依賴
compile'com.eftimoff:android-pathview:1.0.8@aar'
? 2.通過(guò)online免費(fèi)在線文件轉(zhuǎn)換器轉(zhuǎn)換想要改變的簡(jiǎn)單圖片為SVG文件
online網(wǎng)址:https://www.online-convert.com/
?3.將轉(zhuǎn)換后的xml文件存入Studio中res目錄下raw包中
?4.在布局中添加PathView控件
<com.eftimoff.androipathview.PathView
? ? android:id="@+id/mPathView"
? ? app:pathColor="#ff3c00"
? ? app:pathWidth="2dp"
? ? app:svg="@raw/yu"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent" />
app:pathColor="#ff3c00"http://設(shè)線條顏色
app:pathWidth="2dp"http://設(shè)置線條寬度
app:svg="@raw/yu"http://設(shè)置需要展示的矢量圖
5.在Activity中初始化控件通過(guò)鏈?zhǔn)秸{(diào)用來(lái)展示出來(lái)
mPathView = (PathView) findViewById(R.id.mPathView);
mPathView.getPathAnimator()
.delay(500)
.duration(3000)
.listenerEnd(new PathView.AnimatorBuilder.ListenerEnd() {
@Override
? ? ? ? ? ? public void onAnimationEnd() {
Toast.makeText(MainActivity.this,"svg加載成功", Toast.LENGTH_SHORT).show();
}
}).interpolator(new AccelerateInterpolator()).start();