首先要从Iconfont下载图标,一种是svg格式,一种是png格式,如果下载了svg格式,可以用于vector.xml中,用于图片的显示
<?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="60dp" android:height="60dp" android:viewportWidth="1024" android:viewportHeight="1024"> <path android:fillColor="#000000" android:pathData="M941.714,512 Q941.714,655.433,858.002,770.011 T641.719,928.585 Q626.286,931.438,619.154,924.599 T612.023,907.447 L612.023,786.871 Q612.023,731.429,582.327,705.719 Q614.912,702.281,640.914,695.442 T694.637,673.17 T740.936,635.172 T771.217,575.158 T782.92,489.142 Q782.92,419.985,737.791,371.419 Q758.929,319.414,733.22,254.866 Q717.202,249.709,686.921,261.156 T634.368,286.317 L612.645,300.031 Q559.507,285.183,502.931,285.183 T393.217,300.031 Q384.074,293.741,368.934,284.598 T321.208,262.582 T272.056,254.865 Q246.895,319.45,268.07,371.418 Q222.941,419.985,222.941,489.141 Q222.941,537.708,234.644,574.864 T264.633,634.878 T310.64,673.168 T364.363,695.44 T422.95,705.717 Q400.093,726.27,394.936,764.56 Q382.941,770.265,369.226,773.118 T336.641,775.971 T299.228,763.683 T267.521,727.953 Q256.659,709.667,239.8,698.257 T211.53,684.543 L200.083,682.824 Q188.088,682.824,183.516,685.384 T180.663,691.967 T185.82,699.976 T193.244,706.815 L197.23,709.668 Q209.811,715.373,222.099,731.391 T240.092,760.538 L245.797,773.667 Q253.221,795.39,270.958,808.812 T309.248,825.964 T348.965,829.95 T380.672,827.939 L393.801,825.635 Q393.801,847.358,394.094,876.506 T394.387,907.372 Q394.387,917.649,386.963,924.524 T364.106,928.51 Q231.535,884.515,147.823,769.936 T64.111,511.925 Q64.111,392.483,122.954,291.655 T282.661,131.948 T502.931,73.105 T723.201,131.948 T882.908,291.655 T941.751,511.925 Z" /> </vector>大家可能想知道pathData是怎么生成的,需要一个软件svg2android-gh-pages这个软件,可以下载到。或者请移步到这个地址http://blog.csdn.net/lupengfei1009/article/details/51079123,进行查看。然后在项目中设置一下src就可以了。
<ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:src="@drawable/svg_github"/>下载的svg图片只能用在xml中,如果用在PathAnimView中需要下载png图片,然后在vmde软件中进行转化,然后 http://liuyouth.github.io/utils/svg2android/index.html 然后复制粘贴到需要的地方就可以了。以String类型保存。