blob: d626f10b42cb159f225f018c53be17893182a403 [file] [log] [blame]
Yury Khmel9dbde7b2015-08-31 17:51:42 +09001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package android.surfacecomposition;
17
18import android.content.Context;
19import android.view.View;
20import android.view.ViewGroup;
21
22public 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}