SVG是前端的一套标准,Vector是在Android中使用,他只是实现了SVG语言的Path的标签
Vector的常用语法
  M = moveto(M X,Y): 将画笔移动到指定的坐标位置
  L = lineto(L X,Y):画直线到指定的坐标位置
  Z = closepath():关闭路径
  H = horizontal lineto(H X): 画水平线到指定的X坐标位置
  V = vertical lineto(V Y): 画垂直线到指定的Y左边位置
 
Android5.0新动画之VectorDrawable
SVG编辑器
     SVG Editor -http://editor.method.ac
SVG转Vector在线网址
  
VectorDrawable的兼容性
Android5.0新动画之VectorDrawable

 

 
使用AppCompat23.2.0以上的版本才支持VectorDrawable
 
使用静态的VectorDrawable
首先需要对gradle进行配置
 
Android5.0新动画之VectorDrawable

Android5.0新动画之VectorDrawable

 

如果在整个项目的build.gradle里面使用的gradle的版本低于2.1以下的话你就需要进行,额外的配置
Android5.0新动画之VectorDrawable

 

Vector图像标签的含义
Android5.0新动画之VectorDrawable

 

其中只要android:viewportHeight\width的大小不改变,你如果改变android:width\android:height的大小不会影响整个图片的大小
 
在控件中使用静态的VectorDrawable
1.普通控件
直接当作是资源文件使用,但要注意的是,其属性应该使用app:srcCompat="@drawable/"
2带有状态改变的空间如buton
 首先使用selector来引入Vector的资源文件,然后再在使用该控件的地方加入一个静态代码块,
 static{
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
 }
 
使用动态的VectorDrawable

相关文章:

  • 2021-08-09
  • 2022-03-02
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-06-13
猜你喜欢
  • 2021-10-21
  • 2022-12-23
  • 2021-07-08
  • 2022-02-05
  • 2021-10-09
  • 2021-12-28
相关资源
相似解决方案