如何使用AdjustResize设置隐藏键盘下方的BottomNavigationView [英] How to hide the BottomNavigationView below keyboard with adjustResize set

查看:212
本文介绍了如何使用AdjustResize设置隐藏键盘下方的BottomNavigationView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据材料设计规范,出现键盘时,BottomNavigationView应该隐藏在其下方.但是,如果我在活动"清单中设置了android:windowSoftInputMode="adjustResize",则BottomNavigationView会移到键盘上方.

According to the material design spec, when the keyboard appears, the BottomNavigationView should hide underneath it. However, if I set android:windowSoftInputMode="adjustResize" in the Activity's manifest then the BottomNavigationView moves above the keyboard.

我需要设置adjustResize以在键盘打开时启用滚动到屏幕底部的功能.但是,我不希望BottomNavigationView可见.能做到吗?

I need to set adjustResize to enable scrolling to the bottom of the screen while the keyboard is open. However, I do not want the BottomNavigationView to be visible. Can this be done?

当前外观:

布局XML(实际上会有一个FrameLayout,其中EditText在其中,而EditText将在其中):

The layout XML (in reality there would be a FrameLayout where the EditText is and the EditText would be inside it):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Input"
        android:layout_gravity="center"
        android:layout_centerVertical="true"/>

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/colorPrimary"
        app:menu="@menu/menu_bottom_navigation"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"/>

</RelativeLayout>

推荐答案

将此添加到清单中的活动

Add this to your activity in the manifest

android:windowSoftInputMode="adjustPan"

就像

<activity android:name=".feature.home.HomeActivity" 
 android:windowSoftInputMode="adjustPan"/>

这篇关于如何使用AdjustResize设置隐藏键盘下方的BottomNavigationView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆