version:1.0

fix:
update:基本布局实现
This commit is contained in:
2023-02-09 16:03:47 +08:00
parent ace6008709
commit 34433f4f1f
360 changed files with 6211 additions and 8615 deletions

View File

@@ -0,0 +1,183 @@
package com.uiui.zyos.utils;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
/**
* Created by Administrator on 2016/11/25.
* 华为版本 sw480 的内容替换成sw400
*/
public class DimenTool {
public static void gen() {
File file = new File("./app/src/main/res/values/dimens.xml");
BufferedReader reader = null;
StringBuilder sw320 = new StringBuilder();
StringBuilder sw360 = new StringBuilder();
StringBuilder sw400 = new StringBuilder();
StringBuilder sw460 = new StringBuilder();
StringBuilder sw480 = new StringBuilder();
StringBuilder sw560 = new StringBuilder();
StringBuilder sw600 = new StringBuilder();
StringBuilder sw609 = new StringBuilder();
StringBuilder sw640 = new StringBuilder();
StringBuilder sw720 = new StringBuilder();
StringBuilder sw760 = new StringBuilder();
StringBuilder sw800 = new StringBuilder();
StringBuilder sw860 = new StringBuilder();
StringBuilder sw900 = new StringBuilder();
// StringBuilder mdpi = new StringBuilder();
// StringBuilder hdpi = new StringBuilder();
// StringBuilder xhdpi = new StringBuilder();
// StringBuilder xxhdpi = new StringBuilder();
try {
System.out.println("生成不同分辨率:");
reader = new BufferedReader(new FileReader(file));
String tempString;
int line = 1;
// 一次读入一行直到读入null为文件结束
java.text.DecimalFormat df = new java.text.DecimalFormat("#.##");
while ((tempString = reader.readLine()) != null) {
if (tempString.contains("</dimen>")) {
//tempString = tempString.replaceAll(" ", "");
String start = tempString.substring(0, tempString.indexOf(">") + 1);
String end = tempString.substring(tempString.lastIndexOf("<") - 2);
double num = Double.valueOf(tempString.substring(tempString.indexOf(">") + 1, tempString.indexOf("</dimen>") - 2));
sw320.append(start).append(df.format((double) num * 0.4)).append(end).append("\n");
sw360.append(start).append(df.format((double) num * 0.45)).append(end).append("\n");
sw400.append(start).append(df.format((double) num * 0.5)).append(end).append("\n");
sw460.append(start).append(df.format((double) num * 0.575)).append(end).append("\n");
sw480.append(start).append(df.format((double) num * 0.6)).append(end).append("\n");
sw560.append(start).append(df.format((double) num * 0.7)).append(end).append("\n");
sw600.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
sw609.append(start).append(df.format((double) num * 0.76125)).append(end).append("\n");
sw640.append(start).append(df.format((double) num * 0.85)).append(end).append("\n"); // 适配学仕宝
sw720.append(start).append(df.format((double) num * 0.9)).append(end).append("\n");
sw760.append(start).append(df.format((double) num * 0.95)).append(end).append("\n");
sw800.append(tempString).append("\n");
sw860.append(start).append(df.format((double) num * 1.06)).append(end).append("\n");
sw900.append(start).append(df.format((double) num * 1.125)).append(end).append("\n");
// mdpi.append(start).append(df.format((double) num * 0.75)).append(end).append("\n");
// hdpi.append(start).append(df.format((double) num * 1)).append(end).append("\n");
// xhdpi.append(start).append(df.format((double) num * 1.5)).append(end).append("\n");
// xxhdpi.append(start).append(df.format((double) num * 2)).append(end).append("\n");
} else {
sw320.append(tempString).append("\n");
sw360.append(tempString).append("\n");
sw400.append(tempString).append("\n");
sw460.append(tempString).append("\n");
sw480.append(tempString).append("\n");
sw560.append(tempString).append("\n");
sw600.append(tempString).append("\n");
sw609.append(tempString).append("\n");
sw640.append(tempString).append("\n");
sw760.append(tempString).append("\n");
sw720.append(tempString).append("\n");
sw800.append(tempString).append("\n");
sw860.append(tempString).append("\n");
sw900.append(tempString).append("\n");
// mdpi.append(tempString).append("\n");
// hdpi.append(tempString).append("\n");
// xhdpi.append(tempString).append("\n");
// xxhdpi.append(tempString).append("\n");
}
line++;
}
reader.close();
System.out.println("<!-- sw480 -->");
System.out.println(sw480);
System.out.println("<!-- sw600 -->");
System.out.println(sw600);
System.out.println("<!-- sw720 -->");
System.out.println(sw720);
System.out.println("<!-- sw800 -->");
System.out.println(sw800);
String sw320file = "./app/src/main/res/values-sw310dp/dimens.xml";
String sw360file = "./app/src/main/res/values-sw350dp/dimens.xml";
String sw400file = "./app/src/main/res/values-sw390dp/dimens.xml";
String sw460file = "./app/src/main/res/values-sw450dp/dimens.xml";
String sw480file = "./app/src/main/res/values-sw470dp/dimens.xml";
String sw560file = "./app/src/main/res/values-sw550dp/dimens.xml";
String sw600file = "./app/src/main/res/values-sw500dp/dimens.xml";
String sw609file = "./app/src/main/res/values-sw609dp/dimens.xml";
String sw640file = "./app/src/main/res/values-sw630dp/dimens.xml";
String sw720file = "./app/src/main/res/values-sw710dp/dimens.xml";
String sw760file = "./app/src/main/res/values-sw760dp/dimens.xml";
String sw800file = "./app/src/main/res/values-sw800dp/dimens.xml";
String sw860file = "./app/src/main/res/values-sw850dp/dimens.xml";
String sw900file = "./app/src/main/res/values-sw890dp/dimens.xml";
// String mdpifile = "./app/src/main/res/values-mdpi/dimens.xml";
// String hdpifile = "./app/src/main/res/values-hdpi/dimens.xml";
// String xhdpifile = "./app/src/main/res/values-xhdpi/dimens.xml";
// String xxhdpifile = "./app/src/main/res/values-xxhdpi/dimens.xml";
writeFile(sw320file, sw320.toString());
writeFile(sw360file, sw360.toString());
writeFile(sw400file, sw400.toString());
writeFile(sw460file, sw460.toString());
writeFile(sw480file, sw480.toString());
writeFile(sw560file, sw560.toString());
writeFile(sw600file, sw600.toString());
writeFile(sw609file, sw609.toString());
writeFile(sw640file, sw640.toString());
writeFile(sw720file, sw720.toString());
writeFile(sw760file, sw720.toString());
writeFile(sw800file, sw800.toString());
writeFile(sw860file, sw860.toString());
writeFile(sw900file, sw900.toString());
// writeFile(mdpifile, mdpi.toString());
// writeFile(hdpifile, hdpi.toString());
// writeFile(xhdpifile, xhdpi.toString());
// writeFile(xxhdpifile, xxhdpi.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
public static void writeFile(String file, String text) {
PrintWriter out = null;
try {
File file1 = new File(file.replace("/dimens.xml","").trim());
if (!file1.exists()) {
file1.mkdirs();
}
out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
out.println(text);
} catch (IOException e) {
e.printStackTrace();
}
out.close();
}
public static void main(String[] args) {
gen();
}
}