Skip to content

Commit 715026a

Browse files
author
hongyangAndroid
committed
add AutoRadioGroup,AutoTableLayout,AutoTableRow
1 parent ae98375 commit 715026a

File tree

4 files changed

+257
-1
lines changed

4 files changed

+257
-1
lines changed

autolayout-widget/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
compile 'com.android.support:appcompat-v7:23.1.0'
2424
compile project(':autolayout')
2525
compile 'com.android.support:support-v4:23.1.0'
26-
compile 'com.android.support:design:23.0.1'
26+
compile 'com.android.support:design:23.1.1'
2727
compile 'com.android.support:gridlayout-v7:23.1.0'
2828
compile 'com.android.support:cardview-v7:23.1.0'
2929
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package com.zhy.autolayout.widget;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.ViewGroup;
6+
import android.widget.RadioGroup;
7+
8+
import com.zhy.autolayout.AutoLayoutInfo;
9+
import com.zhy.autolayout.utils.AutoLayoutHelper;
10+
11+
/**
12+
* Created by hupei on 2016/2/29 9:59.
13+
*/
14+
public class AutoRadioGroup extends RadioGroup
15+
{
16+
private AutoLayoutHelper mHelper = new AutoLayoutHelper(this);
17+
18+
public AutoRadioGroup(Context context)
19+
{
20+
super(context);
21+
}
22+
23+
public AutoRadioGroup(Context context, AttributeSet attrs)
24+
{
25+
super(context, attrs);
26+
}
27+
28+
29+
@Override
30+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
31+
{
32+
if (!isInEditMode())
33+
mHelper.adjustChildren();
34+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
35+
}
36+
37+
@Override
38+
protected void onLayout(boolean changed, int l, int t, int r, int b)
39+
{
40+
super.onLayout(changed, l, t, r, b);
41+
}
42+
43+
@Override
44+
public LayoutParams generateLayoutParams(AttributeSet attrs)
45+
{
46+
return new LayoutParams(getContext(), attrs);
47+
}
48+
49+
public static class LayoutParams extends RadioGroup.LayoutParams
50+
implements AutoLayoutHelper.AutoLayoutParams
51+
{
52+
private AutoLayoutInfo mAutoLayoutInfo;
53+
54+
public LayoutParams(Context c, AttributeSet attrs)
55+
{
56+
super(c, attrs);
57+
mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs);
58+
}
59+
60+
@Override
61+
public AutoLayoutInfo getAutoLayoutInfo()
62+
{
63+
return mAutoLayoutInfo;
64+
}
65+
66+
67+
public LayoutParams(int width, int height)
68+
{
69+
super(width, height);
70+
}
71+
72+
public LayoutParams(ViewGroup.LayoutParams source)
73+
{
74+
super(source);
75+
}
76+
77+
public LayoutParams(MarginLayoutParams source)
78+
{
79+
super(source);
80+
}
81+
82+
}
83+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.zhy.autolayout.widget;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.ViewGroup;
6+
import android.widget.TableLayout;
7+
8+
import com.zhy.autolayout.AutoLayoutInfo;
9+
import com.zhy.autolayout.utils.AutoLayoutHelper;
10+
11+
/**
12+
* Created by hupei on 2016/2/29 9:59.
13+
*/
14+
public class AutoTableLayout extends TableLayout
15+
{
16+
private AutoLayoutHelper mHelper = new AutoLayoutHelper(this);
17+
18+
public AutoTableLayout(Context context)
19+
{
20+
super(context);
21+
}
22+
23+
public AutoTableLayout(Context context, AttributeSet attrs)
24+
{
25+
super(context, attrs);
26+
}
27+
28+
@Override
29+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
30+
{
31+
if (!isInEditMode())
32+
mHelper.adjustChildren();
33+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
34+
}
35+
36+
37+
@Override
38+
protected void onLayout(boolean changed, int l, int t, int r, int b)
39+
{
40+
super.onLayout(changed, l, t, r, b);
41+
}
42+
43+
44+
@Override
45+
public LayoutParams generateLayoutParams(AttributeSet attrs)
46+
{
47+
return new LayoutParams(getContext(), attrs);
48+
}
49+
50+
51+
public static class LayoutParams extends TableLayout.LayoutParams
52+
implements AutoLayoutHelper.AutoLayoutParams
53+
{
54+
private AutoLayoutInfo mAutoLayoutInfo;
55+
56+
public LayoutParams(Context c, AttributeSet attrs)
57+
{
58+
super(c, attrs);
59+
mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs);
60+
}
61+
62+
@Override
63+
public AutoLayoutInfo getAutoLayoutInfo()
64+
{
65+
return mAutoLayoutInfo;
66+
}
67+
68+
69+
public LayoutParams(int width, int height)
70+
{
71+
super(width, height);
72+
}
73+
74+
75+
public LayoutParams(ViewGroup.LayoutParams source)
76+
{
77+
super(source);
78+
}
79+
80+
public LayoutParams(MarginLayoutParams source)
81+
{
82+
super(source);
83+
}
84+
85+
}
86+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.zhy.autolayout.widget;
2+
3+
import android.content.Context;
4+
import android.util.AttributeSet;
5+
import android.view.ViewGroup;
6+
import android.widget.TableRow;
7+
8+
import com.zhy.autolayout.AutoLayoutInfo;
9+
import com.zhy.autolayout.utils.AutoLayoutHelper;
10+
11+
/**
12+
* Created by hupei on 2016/2/29 9:59.
13+
*/
14+
public class AutoTableRow extends TableRow
15+
{
16+
private AutoLayoutHelper mHelper = new AutoLayoutHelper(this);
17+
18+
public AutoTableRow(Context context)
19+
{
20+
super(context);
21+
}
22+
23+
public AutoTableRow(Context context, AttributeSet attrs)
24+
{
25+
super(context, attrs);
26+
}
27+
28+
29+
@Override
30+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
31+
{
32+
if (!isInEditMode())
33+
mHelper.adjustChildren();
34+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
35+
}
36+
37+
38+
@Override
39+
protected void onLayout(boolean changed, int l, int t, int r, int b)
40+
{
41+
super.onLayout(changed, l, t, r, b);
42+
}
43+
44+
45+
@Override
46+
public LayoutParams generateLayoutParams(AttributeSet attrs)
47+
{
48+
return new LayoutParams(getContext(), attrs);
49+
}
50+
51+
52+
public static class LayoutParams extends TableRow.LayoutParams
53+
implements AutoLayoutHelper.AutoLayoutParams
54+
{
55+
private AutoLayoutInfo mAutoLayoutInfo;
56+
57+
public LayoutParams(Context c, AttributeSet attrs)
58+
{
59+
super(c, attrs);
60+
mAutoLayoutInfo = AutoLayoutHelper.getAutoLayoutInfo(c, attrs);
61+
}
62+
63+
@Override
64+
public AutoLayoutInfo getAutoLayoutInfo()
65+
{
66+
return mAutoLayoutInfo;
67+
}
68+
69+
70+
public LayoutParams(int width, int height)
71+
{
72+
super(width, height);
73+
}
74+
75+
76+
public LayoutParams(ViewGroup.LayoutParams source)
77+
{
78+
super(source);
79+
}
80+
81+
public LayoutParams(MarginLayoutParams source)
82+
{
83+
super(source);
84+
}
85+
86+
}
87+
}

0 commit comments

Comments
 (0)