【发布时间】:2015-08-27 22:23:51
【问题描述】:
我无法阻止系统导航栏掩盖我的内容!
我滚动到 recyclerview 的最底部,但它隐藏在导航栏后面。这是我的 XML 布局。
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include layout="@layout/toolbar"/>
<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.v4.view.ViewPager
android:fitsSystemWindows="true"
android:id="@+id/viewpager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
app:fab_colorNormal="@color/accent"
app:fab_colorPressed="@color/accent_dark" />
这是您在图片中看到的片段布局。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</FrameLayout>
我尝试将 android:fitsSystemWindows="true" 添加到我可以的每一块布局中,但这不起作用。其他线程提到添加从条形计算的边距,但这似乎不是正确的解决方案。我直接从 Google 的 CheesSquare 应用程序演示中获取了这个布局,该应用程序演示了 appbarlayout,它看起来工作正常。
【问题讨论】:
-
不,活动不是全屏的。这是一个标准的活动,没有特殊的标志或任何东西。
-
将合适的 margin_bottom 添加到您的 RecyclerView 或根视图。这应该可以解决您的问题。
-
这是一个很好的解决方法,但我正试图找到问题的根源。这似乎不是正常行为。
-
我也有确切的问题:(
-
你解决过这个问题吗?
标签: android android-fragments android-viewpager navigationbar