DisplayListLayersActivitypublic class DisplayListLayersActivity extends android.app.Activity
Fields Summary |
---|
private static final int | VERTICAL_MARGIN |
Methods Summary |
---|
private void | addChild(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.Button | createButton(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.LinearLayout | createContainer()
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
return layout;
| private int | dipToPx(int size)
return (int) (getResources().getDisplayMetrics().density * size + 0.5f);
| protected void | onCreate(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);
|
|