Search in sources :

Example 26 with GridLayout

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

the class VectorDrawable01 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];
    CheckBox toggle = new CheckBox(this);
    toggle.setText("Toggle");
    toggle.setChecked(true);
    toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ViewGroup vg = (ViewGroup) buttonView.getParent();
            for (int i = 0, count = vg.getChildCount(); i < count; i++) {
                View child = vg.getChildAt(i);
                if (child != buttonView) {
                    child.setEnabled(isChecked);
                }
            }
        }
    });
    container.addView(toggle);
    for (int i = 0; i < icon.length; i++) {
        Button button = new Button(this);
        bArray[i] = button;
        button.setWidth(200);
        button.setBackgroundResource(icon[i]);
        container.addView(button);
        VectorDrawable vd = (VectorDrawable) button.getBackground();
        vd.setAlpha((i + 1) * (0xFF / (icon.length + 1)));
    }
    setContentView(container);
}
Also used : GridLayout(android.widget.GridLayout) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) CompoundButton(android.widget.CompoundButton) Button(android.widget.Button) CheckBox(android.widget.CheckBox) ViewGroup(android.view.ViewGroup) View(android.view.View) CompoundButton(android.widget.CompoundButton) VectorDrawable(android.graphics.drawable.VectorDrawable)

Example 27 with GridLayout

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

the class VectorDrawablePerformance 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);
    Resources res = this.getResources();
    container.setBackgroundColor(0xFF888888);
    VectorDrawable[] d = new VectorDrawable[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) VectorDrawable(android.graphics.drawable.VectorDrawable)

Example 28 with GridLayout

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

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)

Example 29 with GridLayout

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

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

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

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