ActionBar设置Title 居中
getActionBar().setBackgroundDrawable(new ColorDrawable(0xff33bb77));
// 返回箭头(默认不显示)
getActionBar().setDisplayHomeAsUpEnabled(true);
// 左侧图标点击事件使能
getActionBar().setHomeButtonEnabled(true);
// 使左上角图标(系统)是否显示
getActionBar().setDisplayShowHomeEnabled(false);
// 显示标题
getActionBar().setDisplayShowTitleEnabled(false);
//显示自定义视图
getActionBar().setDisplayShowCustomEnabled(true);
TextView textView = new TextView(this);
textView.setText($title);
textView.setTextSize(15);
textView.setTextColor(0xffffffff);
LinearLayout actionbarLayout = new LinearLayout(this);
getActionBar().setCustomView(actionbarLayout,new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.WRAP_CONTENT));
ActionBar.LayoutParams mP = (ActionBar.LayoutParams) actionbarLayout
.getLayoutParams();
mP.gravity = mP.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK| Gravity.CENTER_HORIZONTAL;
actionbarLayout.addView(textView);
getActionBar().setCustomView(actionbarLayout, mP);