Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

huangapple go评论68阅读模式
英文:

Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

问题

My bottom navigation fragments are assuming my activity height instead of my FragmentContainerView's. I would like to know what the cause might be.

This is my bottomNavigation activity:

<?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:id="@+id/root_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/default_background"
    tools:context=".ui.MainActivity">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/fragment_container_tab"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:layout="@layout/fragment_blank" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/nav_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>

My interface is looking something like this, in this particularly case I have a marginBottom of 32dp, but as you can see the view is assuming my activity constraints.

(I'm sorry before I forgot the print)

I expect the result to be something like this, that is my preview screen. I want the bottom of my fragment to be the top of the BottomNavigationView:

Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

I don't know what code can help finding the solution for this issue but I can provide more code if needed

英文:

My bottom navigation fragments are assuming my activity height instead of my FragmentContainerView's. I would like to know what the cause might be.

This is my bottomNavigation activity:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:id=&quot;@+id/root_layout&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:background=&quot;@color/default_background&quot;
    tools:context=&quot;.ui.MainActivity&quot;&gt;

    &lt;androidx.fragment.app.FragmentContainerView
        android:id=&quot;@+id/fragment_container_tab&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;0dp&quot;
        app:layout_constraintBottom_toTopOf=&quot;@+id/bottomNavigationView&quot;
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:layout_constraintTop_toTopOf=&quot;parent&quot;
        tools:layout=&quot;@layout/fragment_blank&quot; /&gt;

    &lt;com.google.android.material.bottomnavigation.BottomNavigationView
        android:id=&quot;@+id/bottomNavigationView&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
        app:layout_constraintEnd_toEndOf=&quot;parent&quot;
        app:layout_constraintStart_toStartOf=&quot;parent&quot;
        app:menu=&quot;@menu/nav_menu&quot; /&gt;

&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;

My interface is looking something like this, in this particularly case I have a marginBottom of 32dp, but as you can see the view is assuming my activity constraints.

Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

(I'm sorry before I forgot the print)

I expect the result to be something like this, that is my preview screen. I want the bottom of my fragment to be the top of the BottomNavigationView:

Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

I don't know what code can help finding the solution for this issue but I can provide more code if needed

答案1

得分: 0

我有两个不同的activity_main文件,其中一个文件在XML中有一个小错误。我不知道第二个activity是如何创建的。

英文:

I had two different activity_main files, and one of the files had a small bug in the XML. I don't know how that second activity was created in the first place.

Why is my bottom navigation assuming my activity height instead of my FragmentContainerView's?

huangapple
  • 本文由 发表于 2023年5月24日 18:31:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定