Skip to content

Commit cc4b969

Browse files
author
hongyangAndroid
committed
解决include标签不显示的问题
1 parent 9265ee2 commit cc4b969

8 files changed

Lines changed: 47 additions & 26 deletions

File tree

autolayout/src/main/java/com/zhy/autolayout/AutoFrameLayout.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ public AutoLayoutHelper.AutoLayoutInfo getPercentLayoutInfo()
110110
return mAutoLayoutInfo;
111111
}
112112

113-
@Override
114-
protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr)
115-
{
116-
AutoLayoutHelper.fetchWidthAndHeight(this, a, widthAttr, heightAttr);
117-
}
113+
118114
}
119115
}

autolayout/src/main/java/com/zhy/autolayout/AutoLayoutActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public View onCreateView(String name, Context context, AttributeSet attrs)
3737

3838
if (view != null) return view;
3939

40-
4140
return super.onCreateView(name, context, attrs);
4241
}
4342

autolayout/src/main/java/com/zhy/autolayout/AutoLayoutHelper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ public AutoLayoutHelper(ViewGroup host)
7171
}
7272

7373

74-
public static void fetchWidthAndHeight(ViewGroup.LayoutParams params, TypedArray array,
75-
int widthAttr, int heightAttr)
76-
{
77-
params.width = array.getLayoutDimension(widthAttr, 0);
78-
params.height = array.getLayoutDimension(heightAttr, 0);
79-
80-
}
81-
8274
public void adjustChildren()
8375
{
8476
for (int i = 0, n = mHost.getChildCount(); i < n; i++)

autolayout/src/main/java/com/zhy/autolayout/AutoLinearLayout.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.zhy.autolayout;
22

33
import android.content.Context;
4-
import android.content.res.TypedArray;
54
import android.util.AttributeSet;
65
import android.view.ViewGroup;
76
import android.widget.LinearLayout;
@@ -36,10 +35,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b)
3635
super.onLayout(changed, l, t, r, b);
3736
}
3837

38+
3939
@Override
4040
public LayoutParams generateLayoutParams(AttributeSet attrs)
4141
{
42-
return new LayoutParams(getContext(), attrs);
42+
return new AutoLinearLayout.LayoutParams(getContext(), attrs);
4343
}
4444

4545

@@ -60,11 +60,6 @@ public AutoLayoutHelper.AutoLayoutInfo getPercentLayoutInfo()
6060
return mAutoLayoutInfo;
6161
}
6262

63-
@Override
64-
protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr)
65-
{
66-
AutoLayoutHelper.fetchWidthAndHeight(this, a, widthAttr, heightAttr);
67-
}
6863

6964
public LayoutParams(int width, int height)
7065
{

autolayout/src/main/java/com/zhy/autolayout/AutoRelativeLayout.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public LayoutParams generateLayoutParams(AttributeSet attrs)
4747
return new LayoutParams(getContext(), attrs);
4848
}
4949

50+
51+
5052
@Override
5153
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
5254
{
@@ -93,10 +95,6 @@ public AutoLayoutHelper.AutoLayoutInfo getPercentLayoutInfo()
9395
return mAutoLayoutInfo;
9496
}
9597

96-
@Override
97-
protected void setBaseAttributes(TypedArray a, int widthAttr, int heightAttr)
98-
{
99-
AutoLayoutHelper.fetchWidthAndHeight(this, a, widthAttr, heightAttr);
100-
}
98+
10199
}
102100
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,10 @@
125125

126126
</RelativeLayout>
127127

128+
<include
129+
layout="@layout/include_test"
130+
>
131+
</include>
132+
128133

129134
</LinearLayout>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
/>
3939

4040

41+
4142
</com.zhy.autolayout.AutoRelativeLayout>
4243

4344

@@ -132,5 +133,7 @@
132133

133134
</com.zhy.autolayout.AutoRelativeLayout>
134135

136+
<include layout="@layout/include_test" ></include>
137+
135138

136139
</com.zhy.autolayout.AutoLinearLayout>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<RelativeLayout
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
android:layout_width="match_parent"
6+
android:layout_height="108px"
7+
android:layout_marginTop="26px"
8+
android:background="#ffffffff"
9+
>
10+
11+
<TextView
12+
android:layout_width="wrap_content"
13+
android:layout_height="wrap_content"
14+
android:layout_marginLeft="22px"
15+
android:layout_marginTop="16px"
16+
android:text="王大炮 From Include"
17+
android:textColor="#333"
18+
android:textSize="28px"
19+
/>
20+
21+
22+
<TextView
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_alignParentBottom="true"
26+
android:layout_marginBottom="16px"
27+
android:layout_marginLeft="22px"
28+
android:text="护照:G50786449"
29+
android:textColor="#999"
30+
android:textSize="26px"
31+
/>
32+
33+
</RelativeLayout>

0 commit comments

Comments
 (0)