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
24a7726271f756dfc6f2ff3bb10fc4167e750fb606Tor Norbyeimport static android.widget.GridLayout.Spec;
25a7726271f756dfc6f2ff3bb10fc4167e750fb606Tor Norbyeimport static android.widget.GridLayout.UNDEFINED;
26a7726271f756dfc6f2ff3bb10fc4167e750fb606Tor Norbyeimport static android.widget.GridLayout.VERTICAL;
27a7726271f756dfc6f2ff3bb10fc4167e750fb606Tor Norbyeimport static android.widget.GridLayout.spec;
28aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
29aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milnepublic class GridLayoutTest extends AbstractLayoutTest {
30aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public ViewGroup create(Context context) {
31aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        GridLayout container = new GridLayout(context);
32aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        container.setOrientation(VERTICAL);
33aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne//        container.setUseDefaultMargins(true);
34aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
35aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
36aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            int va = VERTICAL_ALIGNMENTS[i];
37aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
38aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                int ha = HORIZONTAL_ALIGNMENTS[j];
3993cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                Spec rowSpec = spec(UNDEFINED, null);
4093cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                Spec colSpec = spec(UNDEFINED, null);
4193cd6a6c78683643de51f9e698b38847bd1f1155Philip Milne                GridLayout.LayoutParams lp = new GridLayout.LayoutParams(rowSpec, colSpec);
42f474870fe1189f73cf8ffbaba9e524ef194b5043Philip Milne                //GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
43aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                lp.setGravity(va | ha);
44aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
45aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                container.addView(v, lp);
46aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            }
47aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        }
48aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
49aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return container;
50aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
51aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
52aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public String tag() {
53aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return GridLayoutTest.class.getName();
54aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
55aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne}
56