/**
* 自定义导航视图
* @return
*/
protected void initCustomActionBar() {
ActionBar.LayoutParams lp =
new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
View mActionBarView = LayoutInflater.from(
this).inflate(R.layout.actionbar_custom,
null);
mActionbar = getSupportActionBar();
if (mActionbar ==
null){
return;
}
mActionbar.setCustomView(mActionBarView, lp);
mActionbar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
mActionbar.setDisplayHomeAsUpEnabled(
false);
mActionbar.setHomeButtonEnabled(
true);
mActionbar.setDisplayShowHomeEnabled(
false);
mActionbar.setDisplayShowTitleEnabled(
false);
mActionbar.setDisplayShowCustomEnabled(
true);
Toolbar parent =(Toolbar) mActionBarView.getParent();
parent.setContentInsetsAbsolute(
0,
0);
tvTitle = (TextView) mActionbar.getCustomView().findViewById(R.id.id_top_bar_title);
ImageButton setImgBtn = (ImageButton) mActionBarView.findViewById(R.id.id_right_btn);
backBtn = (ImageButton) mActionBarView.findViewById(R.id.id_left_back_btn);
setImgBtn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
L.e(
"这是设置按钮");
}
});
}