即使打开键盘,如何让 BottomNavigationView 保持向下?
How to let BottomNavigationView stay down even when opening keyboard?
我有一个 editText 视图、一个 RecyclerView 和一个底部导航视图。
当我点击 EditText 时,键盘打开并且 RecyclerView 被填满。但是 BottomNavigationview 仍然位于现在打开的键盘之上,而我的 Recyclerview 位于 bottomnavigation 视图之上。现在,当键盘打开时,recyclerview 和 edittext 正在叠加。有什么办法可以限制bottomnavigationview在键盘打开时消失吗?
这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".Abfahrtsmonitor">
<EditText
android:id="@+id/editText"
android:layout_width="360dp"
android:layout_height="47dp"
android:ems="10"
android:hint="Suche"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="7dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/Recycleview"
android:layout_width="370dp"
android:layout_height="441dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<android.support.design.widget.BottomNavigationView
android:layout_width="368dp"
android:layout_height="48dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="511dp"
android:id="@+id/navigation"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"/>
这是现在的样子:
在清单中定义的 activity 标记中执行以下操作。
<activity
android:name=".YourActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustNothing"/>
在您的 AndroidManifest.xml
中,将以下内容 android:windowSoftInputMode="adjustPan" 添加到您的 activity 中,其中包含 底部导航视图
<application
android:name=".ExampleApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"/>
</application>
这个解决方案对我有效。
从 manifest
中删除 android:windowSoftInputMode
或者您可以将其设置为 stateAlwaysHidden|adjustNothing
。
我有一个 editText 视图、一个 RecyclerView 和一个底部导航视图。 当我点击 EditText 时,键盘打开并且 RecyclerView 被填满。但是 BottomNavigationview 仍然位于现在打开的键盘之上,而我的 Recyclerview 位于 bottomnavigation 视图之上。现在,当键盘打开时,recyclerview 和 edittext 正在叠加。有什么办法可以限制bottomnavigationview在键盘打开时消失吗?
这是我的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".Abfahrtsmonitor">
<EditText
android:id="@+id/editText"
android:layout_width="360dp"
android:layout_height="47dp"
android:ems="10"
android:hint="Suche"
android:inputType="textPersonName"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="7dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/Recycleview"
android:layout_width="370dp"
android:layout_height="441dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<android.support.design.widget.BottomNavigationView
android:layout_width="368dp"
android:layout_height="48dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="511dp"
android:id="@+id/navigation"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"/>
这是现在的样子:
在清单中定义的 activity 标记中执行以下操作。
<activity
android:name=".YourActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustNothing"/>
在您的 AndroidManifest.xml
中,将以下内容 android:windowSoftInputMode="adjustPan" 添加到您的 activity 中,其中包含 底部导航视图
<application
android:name=".ExampleApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"/>
</application>
这个解决方案对我有效。
从 manifest
中删除 android:windowSoftInputMode
或者您可以将其设置为 stateAlwaysHidden|adjustNothing
。