Skip to content

dev #24

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

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

dev #24

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
Binary file removed .idea/caches/build_file_checksums.ser
Binary file not shown.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

36 changes: 0 additions & 36 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@
> Tips:大部分手机的宽度dp值集中在320-450之间,大部分1080P的手机应该都是360dp,390dp,411dp。可以在这个基础上,参考Android studio中的Virtual Device Configuration

![](https://github.com/ladingwu/dimens_sw/blob/master/tips.jpg)


## 使用说明
- clone该项目到本地,以Android项目打开。
- DimenTypes文件中写入你希望适配的sw尺寸,默认的这些尺寸能够覆盖几乎所有手机适配需求
- DimenGenerator文件中填写设计稿的尺寸(DESIGN_WIDTH是设计稿宽度,DESIGN_HEIGHT是设计稿高度)
- 执行lib module中的DimenGenerator.main()方法,当前地址下会生成相应的适配文件,把相应的文件连带文件夹拷贝到正在开发的项目中

## 希望用真机测试的,可运行app项目看效果(效果如下图)

![](https://github.com/ladingwu/dimens_sw/blob/master/test.png)
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void run() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(dm);
tv1.setText("dpi: "+dm.densityDpi +"width Pixe "+dm.widthPixels);
tv2.setText("smallWidthest : "+dm.widthPixels/(dm.densityDpi/160.0) +" dp");
tv3.setText("actual use dimen : "+getResources().getString(R.string.base_dpi));
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = Math.min(dm.widthPixels,dm.heightPixels);
tv1.setText("dpi : "+dm.densityDpi +" smallest width pixels : "+width);
tv2.setText("计算出来的smallestWidth : "+width/(dm.densityDpi/160.0) +"dp");
tv3.setText("实际使用的smallestWidth : "+getResources().getString(R.string.base_dpi));
tv4.setText("当前手机: "+SystemUtil.getDeviceBrand()+" "+SystemUtil.getSystemModel()+ " \n"+"当前系统: "+SystemUtil.getSystemVersion()+ " ");
LinearLayout.LayoutParams p= (LinearLayout.LayoutParams) view.getLayoutParams();
p.width = getResources().getDimensionPixelSize(R.dimen.qb_px_375);
view.setLayoutParams(p);
}
},1000);
},500);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/view_show"
android:layout_width="match_parent"
android:layout_width="200dp"
android:layout_height="@dimen/qb_px_40"
android:background="@drawable/view_shape"
android:layout_marginTop="60dp"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.1'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Nov 26 14:32:56 CST 2018
#Thu Apr 04 17:29:35 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
3 changes: 0 additions & 3 deletions lib/src/main/java/com/example/lib/constants/DimenTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public enum DimenTypes {
DP_sw__370(370),
DP_sw__380(380),
DP_sw__390(390),
DP_sw__391(391),
DP_sw__392(392),
DP_sw__393(393),
DP_sw__410(410),
DP_sw__420(420),
DP_sw__430(430),
Expand Down
Binary file added test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.