Why does TabLayout leave a gap for the NavBar when in immersive mode?

陌路散爱 提交于 2019-12-12 02:45:11

问题


I'm making a tabbed app using the Tabbed Activity template in Android Studio. The client wants the tabs at the bottom and it's for use in a kiosk so I have enables immersive mode etc just fine.

My draft layout looks like this:

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

The AppBarLayout is at the bottom however there's a gap below it for the hidden nav bar:

Any suggestions?


回答1:


It turned out to be a simple fix, set fitsSystemWindows in the root view to false or remove it.

The fitsSystemWindows attribute makes your ListView fit to the edges of the action bar and navigation bar (instead of going under them).

Source



来源:https://stackoverflow.com/questions/33100985/why-does-tablayout-leave-a-gap-for-the-navbar-when-in-immersive-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!