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.LinearLayout;
23aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
24aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milneimport static android.widget.LinearLayout.*;
257fd948756947506db62a2bafca2ed45ff53ac0a0Philip Milneimport static android.widget.LinearLayout.LayoutParams.*;
26aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
27aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milnepublic class LinearLayoutTest extends AbstractLayoutTest {
28aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public ViewGroup create(Context context) {
29aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        LinearLayout container = new LinearLayout(context);
30aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        container.setOrientation(LinearLayout.VERTICAL);
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];
367fd948756947506db62a2bafca2ed45ff53ac0a0Philip Milne                LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
37aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                lp.gravity = va | ha;
38aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
39aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne                container.addView(v, lp);
40aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne            }
41aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        }
42aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
43aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return container;
44aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
45aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne
46aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    public String tag() {
47aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne        return LinearLayoutTest.class.getName();
48aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne    }
49aa616f31fe7c0c8e3657bb9a5889ec5e56ee5232Philip Milne}
50