选项卡上方的操作栏

时间:2015-05-26 13:29:36

标签: java android

  

我正在尝试使用自定义集中文本创建一个操作栏,我尝试使用以下代码,但选项卡视图将显示在自定义文本的操作栏上方,这是我的代码和图像Screen shot of view的屏幕截图:

    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);

0 个答案:

没有答案