Search in sources :

Example 51 with GridLayout

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

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

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

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

the class MyActivity method test2.

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void test2(Bundle savedInstanceState) {
    ActionBar actionBar = getActionBar();
    GridLayout gridLayout = new GridLayout(null);
    int x = View.DRAWING_CACHE_QUALITY_AUTO;
    int y = View.MEASURED_HEIGHT_STATE_SHIFT;
    int alignmentMode = gridLayout.getAlignmentMode();
    gridLayout.setRowOrderPreserved(true);
}
Also used : GridLayout(android.widget.GridLayout) ActionBar(android.app.ActionBar) SuppressLint(android.annotation.SuppressLint) TargetApi(android.annotation.TargetApi)

Example 54 with GridLayout

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

the class AnimatedVectorDrawableTest method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    final int[] layerTypes = { View.LAYER_TYPE_SOFTWARE, View.LAYER_TYPE_HARDWARE };
    final boolean[] forceOnUi = { false, true };
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    GridLayout container = new GridLayout(this);
    scrollView.addView(container);
    container.setColumnCount(layerTypes.length * forceOnUi.length);
    for (int j = 0; j < layerTypes.length; j++) {
        for (int k = 0; k < forceOnUi.length; k++) {
            TextView textView = new TextView(this);
            String category = "Layer:" + (layerTypes[j] == View.LAYER_TYPE_SOFTWARE ? "SW" : "HW") + (forceOnUi[k] == true ? ",forceUI" : "");
            textView.setText(category);
            container.addView(textView);
        }
    }
    for (int i = 0; i < icon.length; i++) {
        for (int j = 0; j < layerTypes.length; j++) {
            for (int k = 0; k < forceOnUi.length; k++) {
                Button button = new Button(this);
                button.setWidth(300);
                button.setHeight(300);
                button.setLayerType(layerTypes[j], null);
                button.setBackgroundResource(icon[i]);
                AnimatedVectorDrawable d = (AnimatedVectorDrawable) button.getBackground();
                if (forceOnUi[k] == true) {
                    d.forceAnimationOnUI();
                }
                d.registerAnimationCallback(new Animatable2.AnimationCallback() {

                    @Override
                    public void onAnimationStart(Drawable drawable) {
                        Log.v(LOGCAT, "Animator start");
                    }

                    @Override
                    public void onAnimationEnd(Drawable drawable) {
                        Log.v(LOGCAT, "Animator end");
                    }
                });
                container.addView(button);
                button.setOnClickListener(this);
            }
        }
    }
    setContentView(scrollView);
}
Also used : AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Drawable(android.graphics.drawable.Drawable) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) Animatable2(android.graphics.drawable.Animatable2) GridLayout(android.widget.GridLayout) ScrollView(android.widget.ScrollView) Button(android.widget.Button) TextView(android.widget.TextView)

Example 55 with GridLayout

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

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)

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