| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.surfacecomposition; |
| 17 |
|
| 18 |
import android.content.Context; |
| 19 |
import android.view.View; |
| 20 |
import android.view.ViewGroup; |
| 21 |
|
| 22 |
public class CustomLayout extends ViewGroup { |
| 23 |
public CustomLayout(Context context) { |
| 24 |
super(context); |
| 25 |
} |
| 26 |
|
| 27 |
public static class LayoutParams extends ViewGroup.LayoutParams { |
| 28 |
private int mLeft, mTop, mRight, mBottom; |
| 29 |
|
| 30 |
public LayoutParams(int left, int top, int right, int bottom) { |
| 31 |
super(0, 0); |
| 32 |
mLeft = left; |
| 33 |
mTop = top; |
| 34 |
mRight = right; |
| 35 |
mBottom = bottom; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
@Override |
| 40 |
protected void onLayout(boolean changed, int l, int t, int r, int b) { |
| 41 |
final int count = getChildCount(); |
| 42 |
for (int i = 0; i < count; i++) { |
| 43 |
View child = getChildAt(i); |
| 44 |
CustomLayout.LayoutParams lp = (CustomLayout.LayoutParams) child.getLayoutParams(); |
| 45 |
child.layout(lp.mLeft, lp.mTop, lp.mRight, lp.mBottom); |
| 46 |
} |
| 47 |
} |
| 48 |
} |