Skip to content

Commit bb17d06

Browse files
author
hongyangAndroid
committed
fix bugs , useDefault()方法判断错误
1 parent cc8889a commit bb17d06

File tree

4 files changed

+74
-57
lines changed

4 files changed

+74
-57
lines changed

autolayout/src/main/java/com/zhy/autolayout/attr/AutoAttr.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public abstract class AutoAttr
1414
protected int baseWidth;
1515
protected int baseHeight;
1616

17-
1817
public AutoAttr(int pxVal, int baseWidth, int baseHeight)
1918
{
2019
this.pxVal = pxVal;
@@ -24,6 +23,7 @@ public AutoAttr(int pxVal, int baseWidth, int baseHeight)
2423

2524
public void apply(View view)
2625
{
26+
2727
int val;
2828
if (useDefault())
2929
{
@@ -56,7 +56,7 @@ protected boolean baseWidth()
5656

5757
protected boolean useDefault()
5858
{
59-
return contains(baseHeight, attrVal()) || contains(baseWidth, attrVal());
59+
return !contains(baseHeight, attrVal()) || !contains(baseWidth, attrVal());
6060
}
6161

6262
protected boolean contains(int baseVal, int flag)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.zhy.autolayout.config;
2+
3+
/**
4+
* Created by zhy on 15/12/5.
5+
* 如果Activity设计稿是横屏,继承该接口即可
6+
*/
7+
public interface UseLandscape
8+
{
9+
}

autolayout/src/main/java/com/zhy/autolayout/utils/L.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
public class L
99
{
10-
public static boolean debug = true;
10+
public static boolean debug = false;
1111
private static final String TAG = "AUTO_LAYOUT";
1212

1313
public static void e(String msg)

sample/src/main/res/layout/activity_square.xml

Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,67 @@
66
android:layout_height="match_parent">
77

88

9-
<LinearLayout android:layout_width="match_parent"
10-
android:layout_height="wrap_content"
11-
android:layout_marginTop="16dp"
12-
android:orientation="horizontal">
13-
14-
<TextView android:layout_width="108px"
15-
android:layout_height="108px"
16-
android:layout_marginLeft="10px"
17-
android:layout_marginRight="20px"
18-
android:background="#44ff0000"
19-
android:gravity="center"
20-
android:text=""
21-
app:layout_auto_basewidth="height"/>
22-
23-
<TextView android:layout_width="108px"
24-
android:layout_height="108px"
25-
android:layout_marginRight="20px"
26-
android:background="#44ff0000"
27-
android:gravity="center"
28-
android:text=""
29-
app:layout_auto_basewidth="height"/>
30-
31-
<TextView android:layout_width="108px"
32-
android:layout_height="108px"
33-
android:layout_marginRight="20px"
34-
android:background="#44ff0000"
35-
android:gravity="center"
36-
android:text=""
37-
app:layout_auto_basewidth="height"/>
38-
39-
<TextView android:layout_width="108px"
40-
android:layout_height="108px"
41-
android:layout_marginRight="20px"
42-
android:background="#44ff0000"
43-
android:gravity="center"
44-
android:text=""
45-
app:layout_auto_basewidth="height"/>
46-
47-
<TextView android:layout_width="108px"
48-
android:layout_height="108px"
49-
android:layout_marginRight="20px"
50-
android:background="#44ff0000"
51-
android:gravity="center"
52-
android:text=""
53-
app:layout_auto_basewidth="height"/>
54-
55-
<TextView android:layout_width="108px"
56-
android:layout_height="108px"
57-
android:layout_marginRight="10px"
58-
android:background="#44ff0000"
59-
android:gravity="center"
60-
android:text=""
61-
app:layout_auto_basewidth="height"/>
9+
<LinearLayout
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:layout_marginTop="16dp"
13+
android:orientation="horizontal">
14+
15+
<TextView
16+
android:layout_width="108px"
17+
android:layout_height="108px"
18+
android:layout_marginLeft="10px"
19+
android:layout_marginRight="20px"
20+
android:background="#44ff0000"
21+
android:gravity="center"
22+
android:tag="auto"
23+
android:text=""
24+
app:layout_auto_basewidth="height"/>
25+
26+
<TextView
27+
android:layout_width="108px"
28+
android:layout_height="108px"
29+
android:layout_marginRight="20px"
30+
android:background="#44ff0000"
31+
android:gravity="center"
32+
android:text=""
33+
app:layout_auto_basewidth="height"/>
34+
35+
<TextView
36+
android:layout_width="108px"
37+
android:layout_height="108px"
38+
android:layout_marginRight="20px"
39+
android:background="#44ff0000"
40+
android:gravity="center"
41+
android:text=""
42+
app:layout_auto_basewidth="height"/>
43+
44+
<TextView
45+
android:layout_width="108px"
46+
android:layout_height="108px"
47+
android:layout_marginRight="20px"
48+
android:background="#44ff0000"
49+
android:gravity="center"
50+
android:text=""
51+
app:layout_auto_basewidth="height"/>
52+
53+
<TextView
54+
android:layout_width="108px"
55+
android:layout_height="108px"
56+
android:layout_marginRight="20px"
57+
android:background="#44ff0000"
58+
android:gravity="center"
59+
android:text=""
60+
app:layout_auto_basewidth="height"/>
61+
62+
<TextView
63+
android:layout_width="108px"
64+
android:layout_height="108px"
65+
android:layout_marginRight="10px"
66+
android:background="#44ff0000"
67+
android:gravity="center"
68+
android:text=""
69+
app:layout_auto_basewidth="height"/>
6270
</LinearLayout>
6371

6472

@@ -77,8 +85,8 @@
7785
<TextView android:layout_width="match_parent"
7886
android:layout_height="match_parent"
7987
android:layout_margin="32px"
80-
android:gravity="center"
8188
android:background="#e5ff1e"
89+
android:gravity="center"
8290
android:text="测试margin,padding等"
8391
app:layout_auto_basewidth="margin">
8492

0 commit comments

Comments
 (0)