Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. 增加负值 2. 增加dimen字符串tip #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/build
/captures
.externalNativeBuild
.idea
11 changes: 9 additions & 2 deletions lib/src/main/java/com/example/lib/utils/MakeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class MakeUtils {
private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
private static final String XML_RESOURCE_START = "<resources>\r\n";
private static final String XML_RESOURCE_END = "</resources>\r\n";
private static final String XML_DIMEN_TEMPLETE = "<dimen name=\"qb_%1$spx_%2$d\">%3$.2fdp</dimen>\r\n";

private static final String XML_DIMEN_TEMPLETE = "<dimen name=\"x%1$sdp_%2$d\">%3$.2fdp</dimen>\r\n";
private static final String XML_DIMEN_TEMPLETE_NAG = "<dimen name=\"x%1$sdp_%2$d_neg\">%3$.2fdp</dimen>\r\n";
private static final String XML_TEST_TIP = "<string name=\"base_dpi\">%ddp</string>\r\n";

private static final String XML_BASE_DPI = "<dimen name=\"base_dpi\">%ddp</dimen>\r\n";
private static final int MAX_SIZE = 720;
Expand Down Expand Up @@ -53,11 +54,17 @@ private static String makeAllDimens(DimenTypes type, int designWidth) {
//备份生成的相关信息
temp = String.format(XML_BASE_DPI, type.getSwWidthDp());
sb.append(temp);

final String xmlTip = String.format(XML_TEST_TIP, type.getSwWidthDp());
sb.append(xmlTip);

for (int i = 0; i <= MAX_SIZE; i++) {

dpValue = px2dip((float) i,type.getSwWidthDp(),designWidth);
temp = String.format(XML_DIMEN_TEMPLETE,"", i, dpValue);
sb.append(temp);
temp = String.format(XML_DIMEN_TEMPLETE_NAG,"", i, -dpValue);
sb.append(temp);
}


Expand Down