android:windowSoftInputMode="adjustPan|adjustResize"
此属性不适用于 collapsingToolbar
。任何人都可以请给我一个修复吗?
我尝试搜索其他一些帖子,但没有找到任何相关的解决方案。
谢谢:)
activity_home.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
...
android:layout_height="150dp">
<com.google.android.material.appbar.CollapsingToolbarLayout
....
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="@+id/contentHome"
layout="@layout/content_home" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
content_home.xml
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/inputName"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
....
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputNameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
...
</com.google.android.material.textfield.TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
答案 0 :(得分:0)
以下是所需的修复:
android:windowSoftInputMode="adjustResize"
CollapsingToolbarLayout
中添加滚动标志:app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlwaysCollapsed"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
不适合您,请尝试使用材料设计:
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
预览: