Панель инструментов, BottomNavigationView и FrameLayout в одном макете XML - PullRequest
0 голосов
/ 11 января 2019

Мне нужна помощь в макете XML, поскольку мне нужно поместить панель инструментов, 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>

1 Ответ

0 голосов
/ 11 января 2019

Попробуйте это

<android.support.constraint.ConstraintLayout 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">

    <include
        android:id="@+id/app_bar"
        layout="@layout/aa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <FrameLayout
        android:id="@+id/activity_content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/colorAccent"
        app:layout_constraintBottom_toTopOf="@+id/horizontalDivider"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/app_bar" />


    <View
        android:id="@+id/horizontalDivider"
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:layout_gravity="center_vertical"
        android:background="@android:color/black"
        app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/activity_content" />


    <include
        android:id="@+id/bottom_navigation"
        layout="@layout/aa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/horizontalDivider" />

</android.support.constraint.ConstraintLayout>

OUTPUT

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...