0

我一直在尝试将 BottomNavigationView 添加到屏幕上。通常它按预期工作,但是当键盘在屏幕中可见时,BottomNavigationView 的高度会意外增加。

我想要的是固定高度,使其与键盘保持一致。BottomNavigationView 和 Keyboard 之间不应有任何间隙。

我添加了代码和屏幕截图来帮助您理解我的问题。

<?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>

错误的 BottomNavigationView 高度。

4

1 回答 1

0

删除 CoordinatorLayout 中的 fitSystemWindows:

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

并在清单文件中更改活动的 windowSoftInputMode :

<activity
        android:name=".YourActivity"
        android:windowSoftInputMode="adjustResize">
于 2020-05-16T13:22:28.087 回答