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

LayoutInsetsTest

public class LayoutInsetsTest extends android.app.Activity

Fields Summary
static int[]
GRAVITIES
Constructors Summary
Methods Summary
public static android.view.Viewcreate(android.content.Context context)


         
        final int N = GRAVITIES.length;

        GridLayout p = new GridLayout(context);
        p.setUseDefaultMargins(true);
        //p.setAlignmentMode(ALIGN_BOUNDS);
        p.setLayoutMode(LAYOUT_MODE_OPTICAL_BOUNDS);

        p.setColumnCount(N);

        for (int i = 0; i < 2*N; i++) {
            View c;
            if (i % 2 == 0) {
                TextView tv = new TextView(context);
                tv.setTextSize(32);
                tv.setText("A");
                c = tv;
            } else {
                Button b = new Button(context);
                b.setBackgroundResource(R.drawable.btn_default_normal);
                b.setText("B");
                c = b;
            }

            LayoutParams lp = new LayoutParams();
            lp.setGravity(GRAVITIES[(i % N)]);
            p.addView(c, lp);

        }


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

        super.onCreate(savedInstanceState);
        //getApplicationInfo().targetSdkVersion = Build.VERSION_CODES.ICE_CREAM_SANDWICH;
        getApplicationInfo().targetSdkVersion = Build.VERSION_CODES.JELLY_BEAN;
        setContentView(create(this));