android custom content layout programatically
public void setContentView(int layoutResID,int actionbarId) {
View newLayout = getLayoutInflater().inflate(R.layout.template_activity_1,null,false);
ViewGroup viewGroup = newLayout.findViewById(R.id.m_new_root);
ViewGroup.LayoutParams para = new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
View oldRoot =getLayoutInflater().inflate(layoutResID,viewGroup,false);
newLayout.setLayoutParams(para);
viewGroup.addView(getLayoutInflater().inflate(actionbarId,viewGroup,false));
viewGroup.addView(oldRoot);
getSupportActionBar().hide();
super.setContentView(newLayout);
}