简体   繁体   中英

BottomNavigationBar disappears when keyboard appears

in my application I have created a custom bottomNavigationView with a LinearLayout.

But I've got a problem, when the virtual keyboard appears my custom navigationView not disappears but instead it becomes smaller and moves to my keyboard.

So can I make it disappear when the keyboard appears? Or somehow can I set the layout like a fixed element ?

This is the layout I'm using

<LinearLayout 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="it.peoople.main.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="20"
    android:orientation="vertical"
    >

    <FrameLayout
        android:id="@+id/head_layout"
        android:layout_width="match_parent"
        android:minHeight="52dp"
        android:layout_height="wrap_content"
        >
    </FrameLayout>

    <FrameLayout
        android:id="@+id/center_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="15"
        >
    </FrameLayout>


</LinearLayout>

<!-- menu -->
<LinearLayout
    android:layout_weight="1.5"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="horizontal"
    android:layout_marginTop="4dp"
    android:layout_marginBottom="4dp"
    >

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/item1"
        />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/item2"
        />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/item3"
        />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/item4"
        />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/item5"
        />

</LinearLayout>

Thank you for your attention.

You still want the soft keyboard to show correct? This will help if want your bottom navigation bar to stay at the bottom and be covered until the soft keyboard hides again.

In your manifest, put this in the activity that you use the keyboard. Like so:

    <activity
        android:name=".YourActivityName"
        //ADD THIS LINE 
        android:windowSoftInputMode="stateHidden|adjustPan" >
    </activity>`here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM