身临其境的模式时,为什么TabLayout在NavBar上留下空白? [英] Why does TabLayout leave a gap for the NavBar when in immersive mode?

查看:114
本文介绍了身临其境的模式时,为什么TabLayout在NavBar上留下空白?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio中的选项卡式活动"模板制作选项卡式应用程序.客户希望标签位于底部,并且可以在自助服务终端中使用,因此我可以启用沉浸式模式等.

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.

我的草稿布局如下:

<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位于底部,但是在其下方有一个隐藏的导航栏:

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

有什么建议吗?

推荐答案

原来是一个简单的修复程序,将root视图中的fitsSystemWindows设置为false或将其删除.

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

fitsSystemWindows属性使您的ListView适应动作栏和导航栏的边缘(而不是进入其下方).

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

来源

这篇关于身临其境的模式时,为什么TabLayout在NavBar上留下空白?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆