2015-10-13 30 views
0

我正在使用Android Studio中的选项卡式活动模板制作选项卡式应用。客户端需要底部的标签,并且可以在信息亭中使用,因此我可以启用身临其境的模式等等。为什么TabLayout在身临其境的模式下为NavBar留下空隙?

我的布局草案看起来是这样的:

<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context=".MainActivity"> 

<android.support.v4.view.ViewPager 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="@dimen/appbar_padding_top" 
    android:theme="@style/AppTheme.AppBarOverlay" 
    android:layout_gravity="bottom"> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/tabs" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

</android.support.design.widget.AppBarLayout> 

</android.support.design.widget.CoordinatorLayout> 

的AppBarLayout是在底部但有一个为隐藏的导航栏下方的缺口:

enter image description here

有什么建议?

+0

的bizzare!尝试进入你的开发人员选项并显示布局范围,仔细检查它不是来自任何元素的边距/填充。 hacky的解决方案是在TabLayout中用当前导航栏大小的dp设置负边距。 –

+0

很棒的建议,但是....随着布局的界限,除了屏幕底部的应用程序视图的最后,没有显示任何界限。设置底部边距实际上隐藏了隐藏区域后面的tabLayout的底部! – Leon

回答

2

原来是一个简单的修复,在根视图中将fitsSystemWindows设置为false或将其删除。

fitsSystemWindows属性使您的ListView适合操作栏和导航栏的边缘(而不是在它们下面)。

Source

相关问题