Search in sources :

Example 61 with GridLayout

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

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

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

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

the class AnimatedVectorDrawableDupPerf 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(5);
    Resources res = this.getResources();
    container.setBackgroundColor(0xFF888888);
    AnimatedVectorDrawable[] d = new AnimatedVectorDrawable[icon.length];
    long time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        d[i] = create(res, icon[i]);
    }
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    TextView t = new TextView(this);
    DecimalFormat df = new DecimalFormat("#.##");
    t.setText("avgL=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
    time = android.os.SystemClock.elapsedRealtimeNanos();
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
    }
    setContentView(scrollView);
    time = android.os.SystemClock.elapsedRealtimeNanos() - time;
    t = new TextView(this);
    t.setText("avgS=" + df.format(time / (icon.length * 1000000.)) + " ms");
    container.addView(t);
}
Also used : GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) Button(android.widget.Button) DecimalFormat(java.text.DecimalFormat) TextView(android.widget.TextView) Resources(android.content.res.Resources) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 64 with GridLayout

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

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

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

the class VectorCheckbox method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GridLayout container = new GridLayout(this);
    container.setColumnCount(5);
    container.setBackgroundColor(0xFF888888);
    final Button[] bArray = new Button[icon.length];
    for (int i = 0; i < icon.length; i++) {
        CheckBox checkBox = new CheckBox(this);
        bArray[i] = checkBox;
        checkBox.setWidth(200);
        checkBox.setButtonDrawable(icon[i]);
        container.addView(checkBox);
    }
    setContentView(container);
}
Also used : GridLayout(android.widget.GridLayout) Button(android.widget.Button) 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