【发布时间】:2021-02-04 08:30:51
【问题描述】:
我的安卓应用中有这样的视图
有一个mainActivity,它有那个bottomNavBar,并且在activity里面有一个片段,底部有两个按钮。
我应该做的是,当软键盘出现时bottomNavBar 应该留在底部(键盘后面)但是这两个按钮应该向上推并在键盘顶部可见
如果我在manifest 文件中为mainActivity 设置android:windowSoftInputMode="adjustResize",那么键盘也会向上推bottomNavBar 和按钮。
如果我将android:windowSoftInputMode="adjustResize" 仅设置为片段(以编程方式),那么它仍然会显示相同的行为。
我该怎么做?任何建议将不胜感激
这是我的活动 xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation"
android:layout_weight="@integer/int_two"/>
<com.google.android.material.bottomnavigation.BottomNavigationView
app:itemIconTint="@drawable/bottom_navigation_selector"
app:itemTextColor="@drawable/bottom_navigation_selector"
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="@integer/int_zero"
android:background="?android:attr/windowBackground"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
app:menu="@menu/bottom_nav_menu" />
</LinearLayout>
</layout>
【问题讨论】:
-
你试过 android:windowSoftInputMode="adjustPan|stateHidden" 吗?
标签: android android-softkeyboard android-bottomnav