http://www.aichengxu.com/other/3372571.htm
http://www.cnblogs.com/his365/p/6078093.html
主要代码:
@Override
protectedvoid onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.sliding_menu_content);
myApplication =(MyApplication) getApplication();
mContext =this;
mActionBar = getSupportActionBar();
View actionbarView=LayoutInflater.from(this).inflate(R.layout.actionbar_layout,null);
ActionBar.LayoutParams layoutParams=newActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.MATCH_PARENT);
layoutParams.gravity =Gravity.CENTER_HORIZONTAL|Gravity.CENTER_HORIZONTAL;
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowCustomEnabled(true);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setCustomView(actionbarView, layoutParams);
Toolbar parent =(Toolbar) actionbarView.getParent();
parent.setContentInsetsAbsolute(0,0);
}
}