BottomNavigationView виден, даже если вид сверху - PullRequest
0 голосов
/ 03 мая 2020

У меня есть экран с 3 основными частями

  • панель инструментов
  • homeContaner (будет содержать фрагменты BottomNavigationView )
  • mainContainer (host spla sh экран или любой экран, занимающий весь экран)

при замене mainContainer на spla sh BottomNavigationView также отображается Я попытался добавить цвет фона к mainContainer и обнаружил, что BottomNavigationView включен Top из mainContainer

также попытался добавить высоту к mainContainer , но не получил новых результатов

Снимки экрана enter image description here

полный код

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".feature.home_Activity.HomeActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="parent"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:titleTextColor="@android:color/white"/>

    <FrameLayout
        android:id="@+id/homeContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="@id/dummy"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbar" />

    <View
        android:id="@+id/dummy"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_10sdp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/navigation" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="1dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:menu="@menu/navigation" />

    <FrameLayout
        android:id="@+id/mainContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:elevation="10dp"
        android:background="#ffaaff"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>

1 Ответ

0 голосов
/ 05 мая 2020

Обтекание BottomNavigationView с LinearLayout решило проблему

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".feature.home_Activity.HomeActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:minHeight="?attr/actionBarSize"
        app:layout_constraintTop_toTopOf="parent"
        app:titleTextColor="@android:color/white" />

    <FrameLayout
        android:id="@+id/homeContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="@id/dummy"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/toolbar" />

    <View
        android:id="@+id/dummy"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_10sdp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/navigationContainer" />

    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/navigationContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/bn_bg"
            app:elevation="1dp"
            app:itemBackground="@drawable/bn_item__bg"
            app:itemIconTint="@color/secondaryTextColor"
            app:itemTextColor="@color/primaryTextColor"
            app:layout_constraintBottom_toBottomOf="parent"
            app:menu="@menu/navigation" />


    </androidx.appcompat.widget.LinearLayoutCompat>


    <FrameLayout
        android:id="@+id/mainContainer"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:elevation="10dp"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>


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