一个 XML 布局中的 Toolbar、BottomNavigationView

我的 XML 布局需要帮助,因为我需要将 Toolbar、FrameLayout、BottomNavigationView 放在一个活动中,下面是我的代码,工具栏没有出现的问题只有 FrameLayout 和 BottomNavigationView


<android.support.constraint.ConstraintLayout

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:fitsSystemWindows="true"

    xmlns:android="http://schemas.android.com/apk/res/android">


    <include

        android:id="@+id/app_bar"

        android:layout_height="wrap_content"

        android:layout_width="wrap_content"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toTopOf="parent"

        layout="@layout/app_bar_layout" />


    <FrameLayout

        android:id="@+id/activity_content"

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toTopOf="@+id/bottom_navigation"

        app:layout_constraintTop_toBottomOf="@+id/app_bar"

        />



    <View

        android:id="@+id/horizontalDivider"

        android:layout_width="match_parent"

        android:layout_height="0.3dp"

        android:layout_above="@+id/bottom_navigation"

        android:layout_gravity="center_vertical"

        android:background="@android:color/black" />



    <include

        android:id="@+id/bottom_navigation"

        layout="@layout/bottom_navigation"

        android:layout_alignParentBottom="true"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        android:layout_height="wrap_content"

        android:layout_width="match_parent"

        />

</android.support.constraint.ConstraintLayout>



喵喵时光机
浏览 184回答 1
1回答

Helenr

试试这个<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"&nbsp; &nbsp; xmlns:app="http://schemas.android.com/apk/res-auto"&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="match_parent">&nbsp; &nbsp; <include&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/app_bar"&nbsp; &nbsp; &nbsp; &nbsp; layout="@layout/aa"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintLeft_toLeftOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintRight_toRightOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toTopOf="parent" />&nbsp; &nbsp; <FrameLayout&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/activity_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="0dp"&nbsp; &nbsp; &nbsp; &nbsp; android:background="@color/colorAccent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintBottom_toTopOf="@+id/horizontalDivider"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintHorizontal_bias="0.5"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintLeft_toLeftOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintRight_toRightOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toBottomOf="@+id/app_bar" />&nbsp; &nbsp; <View&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/horizontalDivider"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="5dp"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_gravity="center_vertical"&nbsp; &nbsp; &nbsp; &nbsp; android:background="@android:color/black"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintLeft_toLeftOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintRight_toRightOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toBottomOf="@+id/activity_content" />&nbsp; &nbsp; <include&nbsp; &nbsp; &nbsp; &nbsp; android:id="@+id/bottom_navigation"&nbsp; &nbsp; &nbsp; &nbsp; layout="@layout/aa"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintBottom_toBottomOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintStart_toStartOf="parent"&nbsp; &nbsp; &nbsp; &nbsp; app:layout_constraintTop_toBottomOf="@+id/horizontalDivider" /></android.support.constraint.ConstraintLayout>输出
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java