【问题标题】:Android actionBar tabs in landscape doesn't occupy full width横向中的Android actionBar选项卡不占据全宽
【发布时间】:2014-10-15 01:21:45
【问题描述】:

我只想在我的操作栏中显示标签,所以我以编程方式隐藏标题和主页图标

    viewPager = (ViewPager) findViewById(R.id.pager); 
    actionBar = getActionBar();
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);

    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);       
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

在纵向模式下一切正常。选项卡占据整个宽度空间。

但如果我切换到横向模式,标签会占据大约 40% 的宽度。

我想在横向模式下展开标签,就像在纵向模式下一样。我尝试了很多东西,但我没有找到任何解决方案。有可能还是只有一种方法是使用 TabHost?

编辑:我的寻呼机布局:

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" /> 

【问题讨论】:

    标签: android tabs android-actionbar landscape


    【解决方案1】:

    你能在你的 XML 文件中显示与 pager 相关的部分吗?以下是您可以向他们提出的一些建议;

    android:layout_width="match_parent"
    
    android:gravity="center_horizontal"
    
    android:layout_centerInParent="true"
    

    或者,尝试将 alignLeft 和 alignRight 属性设置为相同的参考点。

    【讨论】:

      猜你喜欢
      • 2013-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      相关资源
      最近更新 更多