FileDocCategorySizeDatePackage
AlignmentTest.javaAPI DocAndroid 5.1 API4665Thu Mar 12 22:22:44 GMT 2015com.android.test.layout

AlignmentTest

public class AlignmentTest extends android.app.Activity

Fields Summary
public static final String[]
HORIZONTAL_NAMES
public static final android.widget.GridLayout.Alignment[]
HORIZONTAL_ALIGNMENTS
public static final String[]
VERTICAL_NAMES
public static final android.widget.GridLayout.Alignment[]
VERTICAL_ALIGNMENTS
private static android.content.Context
CONTEXT
public static final ViewFactory
BUTTON_FACTORY
public static final ViewFactory
LABEL_FACTORY
public static final ViewFactory
TEXT_FIELD_FACTORY
public static final ViewFactory[]
FACTORIES
Constructors Summary
Methods Summary
public static voidanimate(android.view.View v)


        long start = System.currentTimeMillis();
        int N = 1000;
        for (int i = 0; i < N; i++) {
            ViewGroup.LayoutParams lp = v.getLayoutParams();
            lp.width += 1; // width;
            lp.height += 1; // height;
            v.requestLayout();
            GridLayout p = (GridLayout) v.getParent();
            p.layout(0, 0, 1000 + (i % 2), 500 + (i % 2));
        }
        float time = (float) (System.currentTimeMillis() - start) / N * 1000;
        System.out.println("Time: " + time + "mics");
    
public static android.view.ViewGroupcreate(android.content.Context context1)


         
        CONTEXT = context1;
        GridLayout container = new GridLayout(context1);
        container.setUseDefaultMargins(true);

        for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
            Alignment va = VERTICAL_ALIGNMENTS[i];
            for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
                Alignment ha = HORIZONTAL_ALIGNMENTS[j];
                LayoutParams layoutParams = new LayoutParams(spec(i, va), spec(j, ha));
                String name = VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j];
                ViewFactory factory = FACTORIES[(i + j) % FACTORIES.length];
                container.addView(factory.create(name, 20), layoutParams);
            }
        }

        return container;
    
protected voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        setContentView(create(getBaseContext()));