android - Android adjustResize 和 adjustPan 不起作用
问题描述
我正在使用 CoordinatorLayout 和导航组件 NestedScrollView。我知道已经有很多关于这个问题的问题,但到目前为止我还没有找到解决方案。
我已经尝试过:
添加相对或 ConstraintLayout 作为根
android:fitsSystemWindows="true" (以及几乎所有的组合
)删除
应用程序:layout_behavior="@string/appbar_scrolling_view_behavior"
显现:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="adjustPan">
</activity>
xml(主活动):
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/CustomToolbar"
app:titleTextColor="?attr/secondaryTextColor"
app:layout_scrollFlags="scroll|enterAlways"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom"
android:layout_gravity="bottom"
android:background="@android:color/transparent"
android:elevation="12dp">
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
android:layout_gravity="bottom"
app:menu="@menu/bottom_nav_menu"
app:labelVisibilityMode="unlabeled" />
<FrameLayout
android:id="@+id/fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<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" />
</FrameLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_gravity="bottom|end"
android:layout_marginBottom="68dp"
android:backgroundTint="?attr/primaryDarkColor"
app:borderWidth="0dp"
app:rippleColor="?attr/accentColor"
app:srcCompat="@drawable/ic_baseline_add_24_white" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
nav_host_fragment (NewMemoryFragment) 的内容:
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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"
android:id="@+id/scrollViewNewMemory"
tools:context=".memories.NewMemoryFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout3"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
app:endIconMode="clear_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/constraintLayoutNewMemory"
app:startIconDrawable="@drawable/ic_baseline_title_24">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etMemoryTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_title_newmemory" />
</com.google.android.material.textfield.TextInputLayout>
解决方案
推荐阅读
- c - 如何检查 EOF 是否在 C 中的 getline() 函数中排在第一位?
- unity3d - 如何获得刚体2d在局部空间中的速度
- java - JButton 的图标在悬停时变得像素化
- php - PHP Slim 4 - 使用 firebase JWT 令牌授权 api 请求
- c# - Docker-compose 从另一个容器访问 MySQL 容器
- python - 没有模块名称'configparser' | PyInstaller
- python - python模块,在模块中调用主类
- java - Android Dark Mode/Light Mode - android微调器下拉弹出背景颜色
- c - C循环双向链表,静态头初始化下一个/上一个指向静态头地址的指针
- python - 因式分解,请帮我看看d出了什么问题,我是刚学习的新手