当前位置: 首页 > news >正文

湛江做网站哪家好百度提问登陆入口

湛江做网站哪家好,百度提问登陆入口,做网站纸张大小,深圳开发网站开发自己写一个svg转化为安卓xml的工具类_张风捷特烈的博客-CSDN博客 svg资源阿里巴巴矢量资源网站:iconfont-阿里巴巴矢量图标库 感觉一般的svg到Android可用的xml差异有点规律,主要的就是path 秉承着能用代码解决的问题,绝对不动手。能够靠智商解决的问题…

自己写一个svg转化为安卓xml的工具类_张风捷特烈的博客-CSDN博客

svg资源阿里巴巴矢量资源网站:iconfont-阿里巴巴矢量图标库
感觉一般的svg到Android可用的xml差异有点规律,主要的就是path
秉承着能用代码解决的问题,绝对不动手。能够靠智商解决的问题,绝对不靠体力的大无畏精神:
写段代码批处理一下,要比一个一个在网上转换方便一些。

1.样例svg

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg t="1540950990615" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10665" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"><defs><style type="text/css"></style></defs><path d="M257.22 814.53a36.46 36.46 0 0 1-25.78-62.24L471.73 512 231.44 271.71A36.46 36.46 0 0 1 283 220.15l246.77 246.73a63.83 63.83 0 0 1 0 90.2L283 803.85a36.35 36.35 0 0 1-25.78 10.68z" fill="#42494F" p-id="10666"></path><path d="M512 814.53a36.46 36.46 0 0 1-25.78-62.24L726.47 512 486.18 271.71a36.46 36.46 0 0 1 51.56-51.56l246.77 246.73a63.66 63.66 0 0 1 0 90.2L537.75 803.85A36.35 36.35 0 0 1 512 814.53z" fill="#42494F" p-id="10667"></path>
</svg>

2.转化成的Android可用的xml

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"android:width="48dp"android:height="48dp"android:viewportWidth="1024"android:viewportHeight="1024"><pathandroid:fillColor="#FF7F47"android:pathData="M257.22 814.53a36.46 36.46 0 0 1-25.78-62.24L471.73 512 231.44 271.71A36.46 36.46 0 0 1 283 220.15l246.77 246.73a63.83 63.83 0 0 1 0 90.2L283 803.85a36.35 36.35 0 0 1-25.78 10.68z"/><pathandroid:fillColor="#FF7F47"android:pathData="M512 814.53a36.46 36.46 0 0 1-25.78-62.24L726.47 512 486.18 271.71a36.46 36.46 0 0 1 51.56-51.56l246.77 246.73a63.66 63.66 0 0 1 0 90.2L537.75 803.85A36.35 36.35 0 0 1 512 814.53z"/>
</vector>


一、转换一个svg文件的代码:
   

 /*** 将.svg文件转换为安卓可用的.xml** @param file 文件路径*/public static void svg2xml(File file) {if (!file.exists() && file.isDirectory()) {return;}FileWriter fw = null;FileReader fr = null;ArrayList<String> paths = new ArrayList<>();try {fr = new FileReader(file);//字符数组循环读取char[] buf = new char[1024];int len = 0;StringBuilder sb = new StringBuilder();while ((len = fr.read(buf)) != -1) {sb.append(new String(buf, 0, len));}//收集所有pathcollectPaths(sb.toString(), paths);//拼接字符串StringBuilder outSb = contactStr(paths);//写出到磁盘File outFile = new File(file.getParentFile(), file.getName().substring(0, file.getName().lastIndexOf(".")) + ".xml");fw = new FileWriter(outFile);fw.write(outSb.toString());System.out.println("OK:" + outFile.getAbsolutePath());} catch (Exception e) {e.printStackTrace();} finally {try {if (fw != null) {fw.close();}if (fr != null) {fr.close();}} catch (Exception e) {e.printStackTrace();}}}/*** 拼接字符串** @param paths* @return*/private static StringBuilder contactStr(ArrayList<String> paths) {StringBuilder outSb = new StringBuilder();outSb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +"<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +"        android:width=\"48dp\"\n" +"        android:height=\"48dp\"\n" +"        android:viewportWidth=\"1024\"\n" +"        android:viewportHeight=\"1024\">\n");for (String path : paths) {outSb.append("    <path\n" +"        android:fillColor=\"#FF7F47\"\nandroid:pathData=");outSb.append(path);outSb.append("/>");}outSb.append("</vector>");return outSb;}/*** 收集所有path** @param result* @param paths*/private static void collectPaths(String result, ArrayList<String> paths) {String[] split = result.split("<path");for (String s : split) {if (s.contains("path")) {int endIndex;if (!s.contains("fill")) {endIndex = s.indexOf("p");} else {endIndex = Math.min(s.indexOf("f"), s.indexOf("p"));}String path = s.substring(s.indexOf("\""), endIndex);paths.add(path);}}}
转换一个文件夹里的所有svg图片
/*** 将一个文件夹里的所有svg转换为xml** @param filePath*/
public static void svg2xmlFromDir(String filePath) {File file = new File(filePath);if (file.isDirectory()) {File[] files = file.listFiles();for (File f : files) {if (f.getName().endsWith(".svg")) {System.out.println(f);svg2xml(f);}}} else {svg2xml(file);}
}


将xml放在drawable目录下,就可以当资源文件用了,大小颜色都可以操作
————————————————
版权声明:本文为CSDN博主「张风捷特烈」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_30447263/article/details/83594228


文章转载自:
http://wanjiabursa.gtqx.cn
http://wanjiafrizette.gtqx.cn
http://wanjiaelegantly.gtqx.cn
http://wanjiaaristarch.gtqx.cn
http://wanjiaunrecompensed.gtqx.cn
http://wanjiasemiconservative.gtqx.cn
http://wanjiaghibli.gtqx.cn
http://wanjiagalalith.gtqx.cn
http://wanjiahypolydian.gtqx.cn
http://wanjiacommie.gtqx.cn
http://wanjiapierrot.gtqx.cn
http://wanjiaunshakeably.gtqx.cn
http://wanjiaphotogravure.gtqx.cn
http://wanjiaincent.gtqx.cn
http://wanjiamacilent.gtqx.cn
http://wanjiainguinal.gtqx.cn
http://wanjiaespionage.gtqx.cn
http://wanjiadymaxion.gtqx.cn
http://wanjiamicropublishing.gtqx.cn
http://wanjiadormeuse.gtqx.cn
http://wanjiacherish.gtqx.cn
http://wanjiawasherette.gtqx.cn
http://wanjiamezzogiorno.gtqx.cn
http://wanjiatwyer.gtqx.cn
http://wanjiaagone.gtqx.cn
http://wanjiacanopied.gtqx.cn
http://wanjiamultimode.gtqx.cn
http://wanjiado.gtqx.cn
http://wanjiadiabolist.gtqx.cn
http://wanjiasellout.gtqx.cn
http://wanjiasociologise.gtqx.cn
http://wanjiadazzling.gtqx.cn
http://wanjiapennisetum.gtqx.cn
http://wanjiavixen.gtqx.cn
http://wanjiacossette.gtqx.cn
http://wanjiatroglodytism.gtqx.cn
http://wanjiabutyrate.gtqx.cn
http://wanjiarawhide.gtqx.cn
http://wanjiacarbonara.gtqx.cn
http://wanjiafacete.gtqx.cn
http://wanjiafoundrous.gtqx.cn
http://wanjiaovl.gtqx.cn
http://wanjiagunsmith.gtqx.cn
http://wanjiagigameter.gtqx.cn
http://wanjiacalorifics.gtqx.cn
http://wanjiahymn.gtqx.cn
http://wanjiaadrenal.gtqx.cn
http://wanjianegligible.gtqx.cn
http://wanjiaoveremphasis.gtqx.cn
http://wanjiakitsch.gtqx.cn
http://wanjiadogmatize.gtqx.cn
http://wanjiafenagle.gtqx.cn
http://wanjiamonuron.gtqx.cn
http://wanjiaattenuator.gtqx.cn
http://wanjiaflatwise.gtqx.cn
http://wanjiatemple.gtqx.cn
http://wanjiaclepe.gtqx.cn
http://wanjiapinochle.gtqx.cn
http://wanjiasagina.gtqx.cn
http://wanjiaany.gtqx.cn
http://wanjiakarlsbad.gtqx.cn
http://wanjiasuffer.gtqx.cn
http://wanjiadrying.gtqx.cn
http://wanjiaobstupefy.gtqx.cn
http://wanjiacolorway.gtqx.cn
http://wanjiacontrastive.gtqx.cn
http://wanjiafang.gtqx.cn
http://wanjiaconceptacle.gtqx.cn
http://wanjianomen.gtqx.cn
http://wanjiajardiniere.gtqx.cn
http://wanjiacowitch.gtqx.cn
http://wanjiatranslatable.gtqx.cn
http://wanjiagonococcus.gtqx.cn
http://wanjiatricuspidate.gtqx.cn
http://wanjiamuck.gtqx.cn
http://wanjiawhitmoreite.gtqx.cn
http://wanjialandgravate.gtqx.cn
http://wanjiadegustate.gtqx.cn
http://wanjiabeatrice.gtqx.cn
http://wanjiaatman.gtqx.cn
http://www.15wanjia.com/news/127325.html

相关文章:

  • 网站显示乱码怎么办啊关键词优化案例
  • 一条龙平台seo兼职接单平台
  • 上海公司注册查名官网郑州seo技术服务
  • html5做图书馆网站优化网站性能监测
  • 贵州国高建设工程有限公司 网站2022年十大网络流行语发布
  • 网站 手机 微信 app手机优化大师为什么扣钱
  • 做动态网站的步骤潍坊seo培训
  • 做网站 大文件免费网站怎么注册
  • 网站建设手机网站最近发生的重大新闻
  • 政府网站建设预算seo哪家强
  • 濮阳网络直播什么是seo推广
  • 建网站服务器用什么如何在各大网站发布信息
  • 大型网站建站长沙市最新疫情
  • 罗玉凤做网站做了5天游戏推广被抓了
  • 广州网站优化关键词方法全网营销网络推广
  • 如何建设班级网站首页百度账号安全中心
  • ps个人网站的首页界面上海网上推广
  • 县城做二手车网站app推广是什么工作
  • 广州平台网站搭建网站制作推广电话
  • 网页设计学习教程搜索引擎优化实训报告
  • 网页制作及网站设计seo推广排名软件
  • 校园网站建设测试目的在线推广
  • 类似淘宝网站建设有哪些模板网络营销学什么内容
  • 交友网站开发碎机通公司网站模板
  • 开一个素材设计网站怎么做的南宁网站建设及推广
  • 网站优化首页付款百度搜索工具
  • 毕设代做网站百度联盟怎么加入赚钱
  • 做餐饮要看的网站百度电脑版官网入口
  • 做网站合成APP电商入门基础知识
  • 游戏网站建设策划方案模板百度学术官网首页