? ? ? ? ? ? ? ? ? 簡單的矢量圖方法
? 1.導入依賴
compile'com.eftimoff:android-pathview:1.0.8@aar'
? 2.通過online免費在線文件轉換器轉換想要改變的簡單圖片為SVG文件
online網址:https://www.online-convert.com/
?3.將轉換后的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://設線條顏色
app:pathWidth="2dp"http://設置線條寬度
app:svg="@raw/yu"http://設置需要展示的矢量圖
5.在Activity中初始化控件通過鏈式調用來展示出來
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();