0

PROBLEM

I want my screen like this when soft navigation key open:

Desire when soft navigation key open

But when I open my soft navigation key, it overlaps BottomNavigationView:

In my app

CODE

I use MainActivity: 4 fragment and BottomNavigationView

AndroidManifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
        <activity
            android:name=".AddActivity"
            android:exported="true" />
        <activity
            android:name=".SplashActivity"
            android:noHistory="true"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:exported="true"></activity>
    </application>

layout activity_main.xml

<?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"
    android:background="@color/white"
    tools:context=".MainActivity">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="676dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="@color/white"
        app:menu="@menu/bottom_menu"
        app:itemIconTint="@drawable/drawer_item_color"
        app:itemTextColor="@drawable/drawer_item_color"/>

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/fragmentContainerView"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="674dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/my_nav" />


</androidx.constraintlayout.widget.ConstraintLayout>

bottom_menu.xml in Resource Manager

<item
    android:id="@+id/firstFragment"
    android:icon="@drawable/ic_baseline_sticky_note"
    android:title="@string/menu_first" />
<item
    android:id="@+id/secondFragment"
    android:icon="@drawable/ic_baseline_calendar"
    android:title="@string/menu_second" />
<item
    android:id="@+id/thirdFragment"
    android:icon="@drawable/ic_baseline_person"
    android:title="@string/menu_third" />
<item
    android:id="@+id/fourFragment"
    android:icon="@drawable/ic_baseline_settings"
    android:title="@string/meu_fourth" />

QUESTION:

What I can do to push up the bottom navigation view to top of soft navigation bar when soft navigation bar open?

traccy00
  • 49
  • 10
  • We need to see the layout to decide; the simplest is to add a 56dp margin to the bottom of the BottomNavigationView – Zain Dec 11 '21 at 17:06
  • @traccy00 may this helpful.https://stackoverflow.com/questions/27723322/bottom-soft-navigationbar-overlaps-my-listview – EAS Dec 13 '21 at 05:15

1 Answers1

0

I fix my problem with code im layout activity_main.xml. I create a new project for Bottom Navigation, and I apply it here I'm not understand so much about this fix. Can anyone explain for me

layout activity_main.xml:

<?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=".MainActivity">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="675dp"
        app:layout_constraintStart_toStartOf="parent"
        app:menu="@menu/bottom_menu"
        android:background="@color/white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:itemIconTint="@drawable/drawer_item_color"
        app:itemTextColor="@drawable/drawer_item_color"/>

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/fragmentContainerView"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="606dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/my_nav" />

</androidx.constraintlayout.widget.ConstraintLayout>
traccy00
  • 49
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '21 at 16:13