android: 如何不让导航栏覆盖视图

android: how to not overlay views with the navigation bar

我的布局有问题。我已经在 activity 中实现了带有视图寻呼机的标签栏布局,我一直在研究答案,但没有运气很好地解决它我的问题是我的标签栏有一个元素 android:layout_alignParentBottom="true" .起初它没有显示(下图) tab bar not showing

并添加了一个元素 android:layout_marginBottom="56dp" 来检查它是否真的覆盖在导航栏上,看起来确实如此。 tab bar shows

有人可以帮我解决这个问题吗?我认为我的问题在于样式。 这是我的风格:

<style name="Base.Theme.MyCureTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimary</item>
    <item name="colorAccent">@color/colorPrimary</item>
    <item name="android:textColorPrimary">@color/font_darker_blue</item>
    <item name="android:textColor">@color/font_gray</item>
</style><style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:minHeight">?attr/actionBarSize</item>
    <item name="tabIndicatorColor">@android:color/transparent</item>
</style>


<style name="ToolbarTheme" parent="Widget.AppCompat.Toolbar">
    <item name="actionMenuTextColor">@color/white</item>
    <item name="colorControlNormal">@color/white</item>
    <item name="colorControlActivated">@color/white</item>
    <item name="android:textColorPrimary">@color/white</item>
    <item name="actionButtonStyle">@style/Widget.AppCompat.ActionButton</item>
    <item name="selectableItemBackground">?android:selectableItemBackground</item>
    <item name="selectableItemBackgroundBorderless">?android:selectableItemBackground</item>
    <item name="colorControlHighlight">@color/colorPrimary</item>
</style>

<style name="ToolbarThemeDark"
    parent="Widget.AppCompat.Toolbar">
    <item name="actionMenuTextColor">@color/colorPrimary</item>
    <item name="colorControlNormal">@color/font_gray</item>
</style>

已编辑:

xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_above="@+id/tabs"
    android:background="@color/font_gray"/>

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_alignParentBottom="true"
    android:layout_height="?android:attr/actionBarSize"
    android:background="@color/white"
    android:layout_marginBottom="56dp"
    app:tabGravity="center"/>

<com.mycurepatient.android.widgets.CustomViewPager
    android:id="@+id/viewpager"
    android:layout_above="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

</RelativeLayout>

我通过删除 app:layout_scrollFlags="scroll|enterAlways|snap"

解决了它