@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_bubble_flow); Point size = new Point(); WindowManager w = getWindowManager(); w.getDefaultDisplay().getSize(size); final LayoutInflater inflater = LayoutInflater.from(this); mBubbleFlowView = (BubbleFlowView) findViewById(R.id.bubble_flow); mBubbleFlowView.configure( size.x, getResources().getDimensionPixelSize(R.dimen.bubble_pager_item_width), getResources().getDimensionPixelSize(R.dimen.bubble_pager_item_height)); for (int i = 0; i < 19; i++) { TabView bubble = (TabView) inflater.inflate(R.layout.view_tab, null); mBubbleFlowView.add(bubble, false); } findViewById(R.id.add_bubble_button) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { TabView bubble = (TabView) inflater.inflate(R.layout.view_tab, null); mBubbleFlowView.add(bubble, false); } }); findViewById(R.id.remove_bubble_button) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int centerIndex = mBubbleFlowView.getCenterIndex(); if (centerIndex > -1) { mBubbleFlowView.remove(centerIndex, false, true); } } }); final Button animateButton = (Button) findViewById(R.id.animate_bubble_button); animateButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (mBubbleFlowView.isExpanded()) { mBubbleFlowView.collapse(); animateButton.setText("Expand"); } else { mBubbleFlowView.expand(); animateButton.setText("Collapse"); } } }); }