How to add toolbar programmatically to LinearLayout. I tried the below code, but it is not working.
My class extends FragmentActivity.
Toolbar toolbar = new Toolbar(this);
Toolbar.LayoutParams toolBarParams = new Toolbar.LayoutParams(
Toolbar.LayoutParams.MATCH_PARENT,
R.attr.actionBarSize
);
toolbar.setLayoutParams(toolBarParams);
toolbar.setBackgroundColor(Color.BLUE);
toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
toolbar.setVisibility(View.VISIBLE);
LinearLayout ll = (LinearLayout) findViewById(R.id.activity_search);
ll.addView(toolbar);