Search in sources :

Example 6 with LayoutParams

use of android.widget.GridLayout.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class LayoutInsetsTest method create.

public static View create(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;
}
Also used : GridLayout(android.widget.GridLayout) LayoutParams(android.widget.GridLayout.LayoutParams) Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with LayoutParams

use of android.widget.GridLayout.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class LayoutInsetsTest method create.

public static View create(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;
}
Also used : GridLayout(android.widget.GridLayout) LayoutParams(android.widget.GridLayout.LayoutParams) Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with LayoutParams

use of android.widget.GridLayout.LayoutParams in project android_frameworks_base by crdroidandroid.

the class AlignmentTest method create.

public static ViewGroup create(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;
}
Also used : GridLayout(android.widget.GridLayout) Alignment(android.widget.GridLayout.Alignment) LayoutParams(android.widget.GridLayout.LayoutParams)

Example 9 with LayoutParams

use of android.widget.GridLayout.LayoutParams in project android_frameworks_base by crdroidandroid.

the class LayoutInsetsTest method create.

public static View create(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;
}
Also used : GridLayout(android.widget.GridLayout) LayoutParams(android.widget.GridLayout.LayoutParams) Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

GridLayout (android.widget.GridLayout)9 LayoutParams (android.widget.GridLayout.LayoutParams)9 View (android.view.View)5 Button (android.widget.Button)5 TextView (android.widget.TextView)5 Alignment (android.widget.GridLayout.Alignment)4