首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >布局-如何填补顶栏和底栏之间的空白

问布局-如何填补顶栏和底栏之间的空白
EN

Stack Overflow用户
提问于 2017-02-27 23:56:32
回答 1查看 275关注 0票数 0

我在我的应用程序顶部有一个工具栏,在底部有一个BottomNavigationView (也称为Tab控制器)。

我需要设置一个框架布局,这样才能填补它们之间的空白。这将保存所选选项卡的内容。

这听起来很简单,我有点惊讶我在这里遇到了问题。

我曾尝试使用layout_above和layout_below,但无法渲染帧(背景为黄色,因此我可以看到它)。除非是我添加了一个明确的高度,这显然是我不想做的。

有任何想法,请:

代码语言:javascript
复制
<RelativeLayout
    android:layout_width="match_parent"
        android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar 
                xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
               android:id="@+id/toolbar"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:minHeight="?attr/actionBarSize"
              android:background="#007AFF"
              app:layout_scrollFlags="scroll|enterAlways"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
              app:popupTheme="@style/ThemeOverlay.AppCompat.Dark" />

    <FrameLayout
          android:id="@+id/frame_fragmentholder"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/yellow"
          android:layout_below="@id/toolbar"
          android:layout_above="@id/bottom_nav"/>

    <android.support.design.widget.BottomNavigationView
          android:id="@+id/bottom_nav"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          app:itemIconTint="@drawable/selector"
          app:itemTextColor="@drawable/selector"
          android:background="#007AFF"
          app:menu="@menu/bottombar_menu" />
</RelativeLayout>
EN

回答 1

Stack Overflow用户

发布于 2017-02-28 00:30:05

解决这个问题的方法似乎是将框架的底部边缘设置为底部导航栏的底部边缘,然后通过添加margin_bottom属性来考虑导航栏的高度。这具有使框架的底边成为底栏的上边缘( == top edge )的效果。

代码语言:javascript
复制
   android:layout_alignBottom="@+id/bottom_nav"
   android:layout_marginBottom="?attr/actionBarSize"



  <FrameLayout
          android:id="@+id/frame_fragmentholder"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@color/yellow"
          android:layout_below="@id/toolbar"
          layout_alignBottom="@+id/bottom_nav"
          android:layout_marginBottom="?attr/actionBarSize" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42490145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档