RTL support api level < 15
2016-04-07 11:44
447 查看
(RTL) Right to Left support 4.2 above. But I need support API 15, platform is 4.0.
transfer to this
the first thought is use Notepad++, but there are different dimension, can do replace all. so I wrote a program to solve this. try to use the NIO.2 in java7
here is my code.
I'm fish, I'm on.
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:gravity="end" android:paddingBottom="14dip" android:paddingLeft="16dip" android:paddingRight="16dip" >
transfer to this
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:gravity="end" android:paddingBottom="14dip" android:paddingEnd="16dip" android:paddingLeft="16dip" android:paddingRight="16dip" android:paddingStart="16dip" >
the first thought is use Notepad++, but there are different dimension, can do replace all. so I wrote a program to solve this. try to use the NIO.2 in java7
here is my code.
import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; public class FilterRTL { public static String pathStr = "E:\\workspace\\Pro\\res"; private static int i = 0; public static void main(String[] args) throws IOException { Path path = Paths.get(pathStr); Path absPath = path.toAbsolutePath(); i++; Files.walkFileTree(absPath, new FileVisitor<Path>() { @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { return FileVisitResult.CONTINUE; } @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (file.toString().endsWith(".xml")) { List<String> lines = Files.readAllLines(file, Charset.forName("utf-8")); List<String> results = new ArrayList<>(); for (String it : lines) { results.add(it); //android:layout_marginStart="8dip" //android:layout_marginEnd="8dip" //android:paddingStart="5dp" //android:paddingEnd="5dp" //android:layout_alignParentStart //android:layout_alignParentEnd if (it.contains("android:layout_marginStart")) { String[] data = it.split("\""); results.add("android:layout_marginLeft=\""+data[1]+"\""); }else if (it.contains("android:layout_marginEnd")) { String[] data = it.split("\""); results.add("android:layout_marginRight=\""+data[1]+"\""); }else if (it.contains("android:paddingStart")) { String[] data = it.split("\""); results.add("android:paddingLeft=\""+data[1]+"\""); }else if (it.contains("android:paddingEnd")) { String[] data = it.split("\""); results.add("android:paddingRight=\""+data[1]+"\""); }else if (it.contains("android:layout_alignParentStart")) { String[] data = it.split("\""); results.add("android:layout_alignParentLeft=\""+data[1]+"\""); }else if (it.contains("android:layout_alignParentEnd")) { String[] data = it.split("\""); results.add("android:layout_alignParentRight=\""+data[1]+"\""); } System.out.println(it); } Files.write(file, results, Charset.forName("utf-8")); i++; } return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { return FileVisitResult.CONTINUE; } }); System.out.println(i); } }
I'm fish, I'm on.
相关文章推荐
- 深入Java7的一些新特性以及对脚本语言支持API的介绍
- 使用Java7的Files工具类和Path接口来访问文件的方法
- java7 WatchServiceDemo 文件系统监控
- Pro Java7 Nio.2 学习(第一章)
- java 7 并发 初级 学习记录(1)
- JDK1.5的新特性
- 关于ManagementFactory cannot be resolved的问题!
- 关于ManagementFactory cannot be resolved的问题!
- Java7语法新特性--switch使用字符串
- java7语法新特性--数值字面量改进
- rtl8812驱动分析(二)
- rtl8812驱动分析(一)
- 从右往左的布局( RTL layout )
- java 如何得到ISO 8601 时间格式
- 欢迎使用CSDN-markdown编辑器
- Java中的AQS在Java6和Java7中的一点小不同
- java7新特性——使用ThreadLocalRandom产生并发随机数
- 把Java数组转换为List时的注意事项
- java7的新特性
- Java那些坑(1):Java7的substring