我正在尝试使用自定义集中文本创建一个操作栏,我尝试使用以下代码,但选项卡视图将显示在自定义文本的操作栏上方,这是我的代码和图像的屏幕截图:
actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
LayoutInflater mInflater = LayoutInflater.from(this);
View mCustomView = mInflater.inflate(R.layout.actionbar_custom, null);
TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.text);
mTitleTextView.setText("Logs");
ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
layoutParams.gravity = Gravity.CENTER_HORIZONTAL|Gravity.CENTER_HORIZONTAL;
getActionBar().setCustomView(mCustomView, layoutParams);
actionBar.setCustomView(mCustomView);
actionBar.setDisplayShowCustomEnabled(true);
adapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(adapter);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);