美文网首页
SVG矢量图

SVG矢量图

作者: Android_小菜鸡 | 来源:发表于2018-06-13 15:59 被阅读0次

                  简单的矢量图方法

  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"//设线条颜色

app:pathWidth="2dp"//设置线条宽度

app:svg="@raw/yu"//设置需要展示的矢量图

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();

相关文章

网友评论

      本文标题:SVG矢量图

      本文链接:https://www.haomeiwen.com/subject/joijeftx.html