Skip to content

Commit 40a28e1

Browse files
committed
fix bug
1 parent 1d5b828 commit 40a28e1

File tree

6 files changed

+15
-35
lines changed

6 files changed

+15
-35
lines changed

Library/src/main/java/cn/gavinliu/android/lib/scale/helper/ScaleLayoutHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ public static ScaleLayoutInfo getScaleLayoutInfo(Context context, AttributeSet a
191191
info.bottomPadding = value;
192192
}
193193

194-
value = array.getDimensionPixelSize(R.styleable.ScaleLayout_layout_design_width, 0);
194+
value = array.getInteger(R.styleable.ScaleLayout_layout_design_width, 0);
195195
if (value != 0) {
196196
info = info != null ? info : new ScaleLayoutInfo(context);
197197
info.designWidth = value;
198198
}
199199

200-
value = array.getDimensionPixelSize(R.styleable.ScaleLayout_layout_design_height, 0);
200+
value = array.getInteger(R.styleable.ScaleLayout_layout_design_height, 0);
201201
if (value != 0) {
202202
info = info != null ? info : new ScaleLayoutInfo(context);
203203
info.designHeight = value;

Library/src/main/res/values/attrs.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<enum name="height" value="1" />
88
</attr>
99

10-
<attr name="layout_design_width" format="dimension" />
11-
<attr name="layout_design_height" format="dimension" />
10+
<attr name="layout_design_width" format="integer" />
11+
<attr name="layout_design_height" format="integer" />
1212
<attr name="layout_design_density" format="integer" />
1313

1414
<attr name="layout_width" format="dimension" />

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ float realPixel = (mScreenWidth * designDensity * getPixelSize()) / (designScree
5757
</attr>
5858

5959
<!-- 设计图的相关属性:必须写在 Scale*Layout 中 -->
60-
<attr name="layout_design_width" format="dimension" />
61-
<attr name="layout_design_height" format="dimension" />
62-
<attr name="layout_design_density" format="integer" />
60+
<attr name="layout_design_width" format="integer" /> <!-- eg:1080 -->
61+
<attr name="layout_design_height" format="integer" /> <!-- eg:1920 -->
62+
<attr name="layout_design_density" format="integer" /> <!-- eg:3 -->
6363

64-
<!-- 控件大小间距相关属性 -->
65-
<attr name="layout_width" format="dimension" />
64+
<!-- 控件大小间距相关属性:下面的单位都应该写 dp -->
65+
<attr name="layout_width" format="dimension" />
6666
<attr name="layout_height" format="dimension" />
6767

6868
<attr name="layout_margin" format="dimension" />

Sample/src/main/res/layout/activity_list.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

Sample/src/main/res/layout/activity_main.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
app:layout_design_density="@integer/app_design_density"
6-
app:layout_design_height="@dimen/app_design_height"
7-
app:layout_design_width="@dimen/app_design_width">
6+
app:layout_design_height="@integer/app_design_height"
7+
app:layout_design_width="@integer/app_design_width">
88

99
<TextView
1010
android:id="@+id/view"
@@ -23,8 +23,8 @@
2323
android:layout_below="@id/view"
2424
android:background="#46b"
2525
app:layout_design_density="@integer/app_design_density"
26-
app:layout_design_height="@dimen/app_design_height"
27-
app:layout_design_width="@dimen/app_design_width"
26+
app:layout_design_height="@integer/app_design_height"
27+
app:layout_design_width="@integer/app_design_width"
2828
app:layout_height="300dp"
2929
app:layout_marginTop="5dp"
3030
app:layout_width="300dp">

Sample/src/main/res/values/dimens.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<resources>
22

3-
<dimen name="app_design_width">1080px</dimen>
4-
<dimen name="app_design_height">1920px</dimen>
53
<integer name="app_design_density">3</integer>
4+
<integer name="app_design_width">1080</integer>
5+
<integer name="app_design_height">1920</integer>
66

77
</resources>

0 commit comments

Comments
 (0)