Search in sources :

Example 36 with GridLayout

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

the class BitmapDrawableDupe 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);
    container.setBackgroundColor(0xFF888888);
    DecimalFormat df = new DecimalFormat("#.##");
    long 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;
    TextView 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)

Example 37 with GridLayout

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

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

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

the class Activity1 method onCreate.

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

Example 39 with GridLayout

use of android.widget.GridLayout in project platform_frameworks_base by android.

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

use of android.widget.GridLayout in project platform_frameworks_base by android.

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