我在我的应用程序顶部有一个工具栏,在底部有一个BottomNavigationView (也称为Tab控制器)。
我需要设置一个框架布局,这样才能填补它们之间的空白。这将保存所选选项卡的内容。
这听起来很简单,我有点惊讶我在这里遇到了问题。
我曾尝试使用layout_above和layout_below,但无法渲染帧(背景为黄色,因此我可以看到它)。除非是我添加了一个明确的高度,这显然是我不想做的。
有任何想法,请:
<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>发布于 2017-02-28 00:30:05
解决这个问题的方法似乎是将框架的底部边缘设置为底部导航栏的底部边缘,然后通过添加margin_bottom属性来考虑导航栏的高度。这具有使框架的底边成为底栏的上边缘( == top edge )的效果。
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" />https://stackoverflow.com/questions/42490145
复制相似问题