1aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne/*
2aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * Copyright (C) 2011 The Android Open Source Project
3aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne *
4aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * Licensed under the Apache License, Version 2.0 (the "License");
5aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * you may not use this file except in compliance with the License.
6aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * You may obtain a copy of the License at
7aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne *
8aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne *      http://www.apache.org/licenses/LICENSE-2.0
9aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne *
10aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * Unless required by applicable law or agreed to in writing, software
11aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * distributed under the License is distributed on an "AS IS" BASIS,
12aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * See the License for the specific language governing permissions and
14aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne * limitations under the License.
15aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne */
16aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
17aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milnepackage com.android.test.layout;
18aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
19aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport android.content.Context;
20aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport android.view.View;
21aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport android.view.ViewGroup;
22aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport android.widget.GridLayout;
23aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
24aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport static android.widget.GridLayout.*;
25aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
26aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milnepublic class GridLayoutTest extends AbstractLayoutTest {
27aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public ViewGroup create(Context context) {
28aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        GridLayout container = new GridLayout(context);
29aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        container.setOrientation(VERTICAL);
30aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne//        container.setUseDefaultMargins(true);
31aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
32aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
33aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            int va = VERTICAL_ALIGNMENTS[i];
34aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
35aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                int ha = HORIZONTAL_ALIGNMENTS[j];
3693cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                Spec rowSpec = spec(UNDEFINED, null);
3793cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                Spec colSpec = spec(UNDEFINED, null);
3893cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                GridLayout.LayoutParams lp = new GridLayout.LayoutParams(rowSpec, colSpec);
39f474870fe1189f73cf8ffbaba9e524ef194b5043Philip Milne                //GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
40aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                lp.setGravity(va | ha);
41aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
42aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                container.addView(v, lp);
43aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            }
44aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        }
45aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
46aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return container;
47aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
48aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
49aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public String tag() {
50aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return GridLayoutTest.class.getName();
51aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
52aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne}
53