Search in sources :

Example 66 with GridLayout

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

the class ActivityTransition method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    setContentView(R.layout.activity_transition);
    setupHero();
    // Ensure that all images are visible regardless of orientation.
    GridLayout gridLayout = (GridLayout) findViewById(R.id.transition_grid_layout);
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    gridLayout.setRowCount(isPortrait ? 4 : 2);
    gridLayout.setColumnCount(isPortrait ? 2 : 4);
}
Also used : GridLayout(android.widget.GridLayout) ColorDrawable(android.graphics.drawable.ColorDrawable)

Example 67 with GridLayout

use of android.widget.GridLayout 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 68 with GridLayout

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

the class GridLayoutTest method create.

public ViewGroup create(Context context) {
    GridLayout container = new GridLayout(context);
    container.setOrientation(VERTICAL);
    for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
        int va = VERTICAL_ALIGNMENTS[i];
        for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
            int ha = HORIZONTAL_ALIGNMENTS[j];
            Spec rowSpec = spec(UNDEFINED, null);
            Spec colSpec = spec(UNDEFINED, null);
            GridLayout.LayoutParams lp = new GridLayout.LayoutParams(rowSpec, colSpec);
            //GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
            lp.setGravity(va | ha);
            View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
            container.addView(v, lp);
        }
    }
    return container;
}
Also used : GridLayout(android.widget.GridLayout) Spec(android.widget.GridLayout.Spec) View(android.view.View)

Example 69 with GridLayout

use of android.widget.GridLayout 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)

Example 70 with GridLayout

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

the class AnimatedStateVectorDrawableTest method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    GridLayout container = new GridLayout(this);
    scrollView.addView(container);
    container.setColumnCount(2);
    for (int i = 0; i < icon.length; i++) {
        CheckBox button = new CheckBox(this);
        button.setWidth(400);
        button.setHeight(400);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
    }
    setContentView(scrollView);
}
Also used : GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) CheckBox(android.widget.CheckBox)

Aggregations

GridLayout (android.widget.GridLayout)75 Button (android.widget.Button)37 TextView (android.widget.TextView)33 ScrollView (android.widget.ScrollView)24 View (android.view.View)15 CheckBox (android.widget.CheckBox)12 Spec (android.widget.GridLayout.Spec)12 DecimalFormat (java.text.DecimalFormat)12 ViewGroup (android.view.ViewGroup)9 LayoutParams (android.widget.GridLayout.LayoutParams)9 Resources (android.content.res.Resources)8 AnimatedVectorDrawable (android.graphics.drawable.AnimatedVectorDrawable)8 VectorDrawable (android.graphics.drawable.VectorDrawable)8 EditText (android.widget.EditText)8 Space (android.widget.Space)8 Drawable (android.graphics.drawable.Drawable)5 Animatable2 (android.graphics.drawable.Animatable2)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 LayoutParams (android.view.ViewGroup.LayoutParams)4 CompoundButton (android.widget.CompoundButton)4