zoha131
zoha131

Reputation: 1888

BottomNavigationView's height get increased when soft keyboard is visible in the screen. How to fix it's height?

I have been trying to add BottomNavigationView to a screen. Normally it works as expected but when the keyboard is visible in the screen the height of the BottomNavigationView gets increased unexpectedly.

What I want is to fix the height so that it sticks with the keyboard. There should not be any gaps between BottomNavigationView and Keyboard.

I have added code and screenshot to help you understand my problem.

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

       <!-- Other views -->

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNav"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:menu="@menu/bottom_navigation_menu" />


    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <!-- Other views -->

</androidx.drawerlayout.widget.DrawerLayout>

wrong BottomNavigationView height.

Upvotes: 2

Views: 523

Answers (1)

Kasım &#214;zdemir
Kasım &#214;zdemir

Reputation: 5634

remove fitsSystemWindows in CoordinatorLayout:

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"> 

and change windowSoftInputMode of your activity in manifest file :

<activity
        android:name=".YourActivity"
        android:windowSoftInputMode="adjustResize">

Upvotes: 1

Related Questions