FileDocCategorySizeDatePackage
DisplayListLayersActivity.javaAPI DocAndroid 5.1 API4071Thu Mar 12 22:22:44 GMT 2015com.android.test.hwui

DisplayListLayersActivity

public class DisplayListLayersActivity extends android.app.Activity

Fields Summary
private static final int
VERTICAL_MARGIN
Constructors Summary
Methods Summary
private voidaddChild(android.widget.LinearLayout root, android.view.View child, int width, int height)

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
        params.gravity = Gravity.CENTER_HORIZONTAL;
        params.setMargins(0, dipToPx(VERTICAL_MARGIN), 0, 0);
        root.addView(child, params);
    
private android.widget.ButtoncreateButton(android.widget.LinearLayout root)

        Button button = new Button(this);
        button.setText("Invalidate");
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                for (int i = 0; i < root.getChildCount(); i++) {
                    View child = root.getChildAt(i);
                    if (child != v) {
                        child.invalidate();
                    }
                }
            }
        });

        return button;
    
private android.widget.LinearLayoutcreateContainer()

        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        return layout;
    
private intdipToPx(int size)

        return (int) (getResources().getDisplayMetrics().density * size + 0.5f);
    
protected voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);

        LinearLayout root = createContainer();
        addChild(root, new LayerView(this, 0xffff0000, LAYER_TYPE_HARDWARE, "hardware"),
                WRAP_CONTENT, WRAP_CONTENT);
        addChild(root, new LayerView(this, 0xff0000ff, LAYER_TYPE_SOFTWARE, "software"),
                WRAP_CONTENT, WRAP_CONTENT);
        addChild(root, createButton(root), WRAP_CONTENT, WRAP_CONTENT);

        setContentView(root);