Search in sources :

Example 21 with GridLayout

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

the class ScaleDrawableTests 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(4);
    container.setBackgroundColor(0xFF888888);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    params.width = 300;
    params.height = 200;
    for (int i = 0; i < scaleTypes.length; i++) {
        TextView t = new TextView(this);
        t.setText(scaleTypes[i]);
        container.addView(t);
        ImageView.ScaleType scaleType = ImageView.ScaleType.values()[i];
        ImageView png_view = new ImageView(this);
        png_view.setLayoutParams(params);
        png_view.setScaleType(scaleType);
        png_view.setImageResource(icon);
        container.addView(png_view);
        ImageView view = new ImageView(this);
        view.setLayoutParams(params);
        view.setScaleType(scaleType);
        view.setImageResource(vector_icon);
        container.addView(view);
        ImageView avd_view = new ImageView(this);
        avd_view.setLayoutParams(params);
        avd_view.setScaleType(scaleType);
        avd_view.setImageResource(animated_vector_icon);
        container.addView(avd_view);
    }
    setContentView(scrollView);
}
Also used : GridLayout(android.widget.GridLayout) LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 22 with GridLayout

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

the class Activity1 method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new GridLayout(getBaseContext()));
}
Also used : GridLayout(android.widget.GridLayout)

Example 23 with GridLayout

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

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 24 with GridLayout

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

the class AlignmentTest method animate.

public static void animate(View v) {
    long start = System.currentTimeMillis();
    int N = 1000;
    for (int i = 0; i < N; i++) {
        ViewGroup.LayoutParams lp = v.getLayoutParams();
        // width;
        lp.width += 1;
        // height;
        lp.height += 1;
        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");
}
Also used : GridLayout(android.widget.GridLayout) ViewGroup(android.view.ViewGroup)

Example 25 with GridLayout

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

the class BiDiTestGridLayoutCodeRtl method create.

public static View create(Context context) {
    GridLayout layout = new GridLayout(context);
    layout.setUseDefaultMargins(true);
    layout.setAlignmentMode(ALIGN_BOUNDS);
    layout.setRowOrderPreserved(false);
    layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    Spec row1 = spec(0);
    Spec row2 = spec(1);
    Spec row3 = spec(2, BASELINE);
    Spec row4 = spec(3, BASELINE);
    // allow the last two rows to overlap the middle two
    Spec row5 = spec(2, 3, FILL);
    Spec row6 = spec(5);
    Spec row7 = spec(6);
    Spec col1a = spec(0, 4, CENTER);
    Spec col1b = spec(0, 4, LEFT);
    Spec col1c = spec(0, RIGHT);
    Spec col2 = spec(1, START);
    Spec col3 = spec(2, FILL);
    Spec col4a = spec(3);
    Spec col4b = spec(3, FILL);
    {
        TextView c = new TextView(context);
        c.setTextSize(32);
        c.setText("Email setup");
        layout.addView(c, new GridLayout.LayoutParams(row1, col1a));
    }
    {
        TextView c = new TextView(context);
        c.setTextSize(16);
        c.setText("You can configure email in just a few steps:");
        layout.addView(c, new GridLayout.LayoutParams(row2, col1b));
    }
    {
        TextView c = new TextView(context);
        c.setText("Email address:");
        layout.addView(c, new GridLayout.LayoutParams(row3, col1c));
    }
    {
        EditText c = new EditText(context);
        c.setEms(10);
        c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        layout.addView(c, new GridLayout.LayoutParams(row3, col2));
    }
    {
        TextView c = new TextView(context);
        c.setText("Password:");
        layout.addView(c, new GridLayout.LayoutParams(row4, col1c));
    }
    {
        TextView c = new EditText(context);
        c.setEms(8);
        c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
        layout.addView(c, new GridLayout.LayoutParams(row4, col2));
    }
    {
        Space c = new Space(context);
        layout.addView(c, new GridLayout.LayoutParams(row5, col3));
    }
    {
        Button c = new Button(context);
        c.setText("Manual setup");
        layout.addView(c, new GridLayout.LayoutParams(row6, col4a));
    }
    {
        Button c = new Button(context);
        c.setText("Next");
        layout.addView(c, new GridLayout.LayoutParams(row7, col4b));
    }
    return layout;
}
Also used : EditText(android.widget.EditText) Space(android.widget.Space) GridLayout(android.widget.GridLayout) Button(android.widget.Button) TextView(android.widget.TextView) Spec(android.widget.GridLayout.Spec)

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