@@ -28,7 +28,6 @@ public class AutoLayoutHelper
2828{
2929 private final ViewGroup mHost ;
3030
31-
3231 private static final int [] LL = new int []
3332 { //
3433 android .R .attr .textSize ,
@@ -98,6 +97,8 @@ public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec)
9897 {
9998 supportTextSize (view , info );
10099
100+ supportPadding (view , info );
101+
101102 if (params instanceof ViewGroup .MarginLayoutParams )
102103 {
103104 info .fillMarginLayoutParams ((ViewGroup .MarginLayoutParams ) params ,
@@ -113,6 +114,46 @@ public void adjustChildren(int widthMeasureSpec, int heightMeasureSpec)
113114
114115 }
115116
117+ private void supportPadding (View view , AutoLayoutInfo info )
118+ {
119+
120+ int mAvailableWidth = AutoLayout .getInstance ().getAvailableWidth ();
121+ int mAvailaleHegiht = AutoLayout .getInstance ().getAvailaleHeight ();
122+ int mDesignWidth = AutoLayout .getInstance ().getDesignWidth ();
123+ int mDesignHeight = AutoLayout .getInstance ().getDesignHeight ();
124+
125+ int left = view .getPaddingLeft (), right = view .getPaddingRight (), top = view .getPaddingTop (), bottom = view .getPaddingBottom ();
126+
127+ if (info .padding != 0 )
128+ {
129+ int vertical = (int ) (info .padding * 1.0f / mDesignHeight * mAvailaleHegiht );
130+ int horizon = (int ) (info .padding * 1.0f / mDesignWidth * mAvailableWidth );
131+ left = right = horizon ;
132+ top = bottom = vertical ;
133+ }
134+ if (info .paddingLeft != 0 )
135+ {
136+ left = (int ) (info .paddingLeft * 1.0f / mDesignWidth * mAvailableWidth );
137+ }
138+
139+ if (info .paddingTop != 0 )
140+ {
141+ top = (int ) (info .paddingLeft * 1.0f / mDesignHeight * mAvailaleHegiht );
142+ }
143+
144+ if (info .paddingRight != 0 )
145+ {
146+ right = (int ) (info .paddingRight * 1.0f / mDesignHeight * mAvailaleHegiht );
147+ }
148+
149+ if (info .paddingBottom != 0 )
150+ {
151+ bottom = (int ) (info .paddingBottom * 1.0f / mDesignHeight * mAvailaleHegiht );
152+ }
153+
154+ view .setPadding (left , top , right , bottom );
155+ }
156+
116157 private void supportTextSize (View view , AutoLayoutInfo info )
117158 {
118159 if (!(view instanceof TextView )) return ;
@@ -295,8 +336,6 @@ public void fillMarginLayoutParams(ViewGroup.MarginLayoutParams params, int widt
295336 }
296337 fillLayoutParams (params , widthHint , heightHint );
297338 }
298-
299-
300339 }
301340
302341 public interface AutoLayoutParams
0 commit comments